Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote