Beginner Case 5 of 50

Case 005: The Top Order

orders

The manager is scrolling through yesterday's order list, thinking out loud.

"Actually — forget setting a cutoff," the manager says. "Could you just tell me the single biggest order we've ever had? I want a number for the board deck."

The data Alex is looking at

orders
idcustomer_idproductamountorder_date
1011Keyboard25002026-01-05
1023Mouse12002026-01-08
1032Headphones35002026-01-10
1044Monitor120002026-01-12
1051Webcam45002026-02-03
… 4 more rows
TASK

Help Alex answer the manager:

“Find the single most expensive order.”
SQL editor Ctrl+Enter to run
Write a query above and hit Run to see what comes back.
No hints requested yet — click "Get a hint" when you're stuck.
Alex's final query — this is for reference. Copy it into your own thinking, not into the editor above.
SELECT * FROM orders ORDER BY amount DESC LIMIT 1;
What that query returns
Case Debrief ORDER BY, LIMIT
  • ORDER BY sorts the rows before anything else happens — ORDER BY amount DESC puts the biggest order first; drop the DESC and it sorts smallest first instead.
  • LIMIT then cuts down that sorted list — LIMIT 1 keeps only the first row, which is why sorting biggest-first and keeping just row 1 gives you the single biggest order.
  • Together, ORDER BY + LIMIT answer any "top N" or "bottom N" question.
  • Quick tip: when all you need is the single biggest or smallest VALUE itself — not the whole row it came from — MAX(amount) or MIN(amount) gets there in one step, no ORDER BY or LIMIT needed. This case asks for the full order row, which is why ORDER BY + LIMIT is the right tool here instead.

Case closed.

Ready for the next one?

Next: Case 006 — Whose Order Is This? →