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
| id | customer_id | product | amount | order_date |
|---|---|---|---|---|
| 101 | 1 | Keyboard | 2500 | 2026-01-05 |
| 102 | 3 | Mouse | 1200 | 2026-01-08 |
| 103 | 2 | Headphones | 3500 | 2026-01-10 |
| 104 | 4 | Monitor | 12000 | 2026-01-12 |
| 105 | 1 | Webcam | 4500 | 2026-02-03 |
| … 4 more rows | ||||
TASK
Help Alex answer the manager:
“Find the single most expensive order.”
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.