Skip to content
Advertisement

Single Item Order – AdventureWorks

I am wondering if my answer works for this problem? The answer I was able to find on the internet seems similar but they join another table which seems ambiguous.

Question: A “Single Item Order” is a customer order where only one item is ordered. Show the SalesOrderID and the UnitPrice for every Single Item Order.

Their answer:

My Answer:

Advertisement

Answer

If you run your answer, you’ll get an error because UnitPrice is not in the GROUP BY. If you add it, your HAVING will not work.

The solution is simple . . . you need an aggregation function:

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