Skip to content
Advertisement

unexpected output with group by

Here is the DDL and DML:

when I select customer_name and product_bought with group by:

the result is surprisingly not grouped by name automatically – I thought with group by the result should be grouped by customer_name and product_bought but we can see james is separated and scattered instead of grouped together. enter image description here

Now I’d like to find the customers who bought both A and B, and here is my query:

and the result is surprising include ada who should not be there:

enter image description here

where am I wrong with these two questions? Thanks

Advertisement

Answer

You can try the below – DEMO Here

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement