Find the orderNumber and amount for the top 5 largest orders placed. (Not just t
ID: 3537657 • Letter: F
Question
Find the orderNumber and amount for the top 5 largest orders placed. (Not just the largest line item value, but the largest dollar amount for the orders).
Tip: Sort your output and use LIMIT. You have to use a trick to sort and it%u2019ll drive you crazy if you don%u2019t know the secret: In the SELECT clause use an alias for the sum:
SUM( %u2026 ) AS Amt
Then refer to the alias when you sort: ORDER BY Amt
Remember that you can sort in both ascending (the default) and descending (DESC) order.
Explanation / Answer
SELECT orderNumber,priceEach,Sum(priceEach) as Amt FROM OrderDetails LIMIT 5 ORDER BY priceEach DESC;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.