Sign in to run and submit your work
Reading is open to everyone. Running code and saving drafts need an account so your work is yours and comes back on your next visit.
or
CODE WORKSPACE
Return order_id and total_amount for orders whose amount is above the overall average.
Result columns · in this order
order_id | Order identifier; unique in this table. |
total_amount | Order total in dollars. |
How to approach it
Compare total_amount to SELECT AVG(total_amount) FROM orders.
Sample input
| order_id | total_amount |
|---|---|
| 1001 | 80 |
| 1004 | 220 |
| 1005 | 540 |
| 1009 | 30 |
| 1010 | 640 |
5 rows — all rows shown.
Expected output
| order_id | total_amount |
|---|---|
| 1010 | 640 |
| 1005 | 540 |
| 1004 | 220 |
3 rows — all rows shown.
Constraints
Use a scalar subquery in WHERE. Order by total_amount DESC, order_id ASC.
Expected skills
Scalar subquery thresholds and deterministic ordering.
Submit for review to find out what your query gets right, what it gets wrong, and how it compares with the best working query for this exercise.
This scenario runs a full workspace — editor, canvas and results side by side. It needs a laptop or desktop to be usable. Open this page on a bigger screen to start building.