Beginner
Case 18 of 50
Case 018: Above Average
payments
ByteMart has grown — Alex is now working with the full order database, not just a handful of rows.
The manager wants outliers: "Which payments were unusually large?"
The data Alex is looking at
payments
| id | order_id | amount |
|---|---|---|
| 601 | 101 | 6200 |
| 602 | 102 | 3500 |
| 603 | 103 | 3600 |
| 604 | 104 | 60000 |
| 605 | 105 | 12000 |
| … 23 more rows | ||
TASK
Help Alex answer the manager:
“Find every payment that is larger than the average payment amount.”
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 payments
WHERE amount > (SELECT AVG(amount) FROM payments);
What that query returns
Case Debrief
Scalar subquery
- A subquery in WHERE lets you compare each row against a value calculated from the whole table — here, the average.