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 status and orders, the count of orders for each status, grouped by status and ordered by orders descending, then status ascending.
Result columns · in this order
statusordersHow to approach it
GROUP BY status with COUNT(*) AS orders, then ORDER BY orders DESC, status ASC.
Sample input
| order_id | status |
|---|---|
| 1001 | paid |
| 1002 | paid |
| 1003 | pending |
| 1004 | shipped |
| 1005 | paid |
| 1006 | refunded |
| 1007 | paid |
| 1008 | shipped |
| 1009 | pending |
| 1010 | paid |
| 1011 | paid |
| 1012 | shipped |
12 rows — scroll inside the table to see them all.
Expected output
| status | orders |
|---|---|
| paid | 6 |
| shipped | 3 |
| pending | 2 |
| refunded | 1 |
4 rows — all rows shown.
Constraints
Use GROUP BY status with COUNT(*) aliased as orders. Order by orders DESC, then status ASC so ties are deterministic.
Expected skills
Grouped counts as a distribution sanity check and deterministic ordering of grouped results.
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.