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
idorder_idamount
6011016200
6021023500
6031033600
60410460000
60510512000
… 23 more rows
TASK

Help Alex answer the manager:

“Find every payment that is larger than the average payment amount.”
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 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.

Case closed.

Ready for the next one?

Next: Case 019 — Audio Buyers →