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 exactly country_bucket, paid_orders, and paid_revenue for January 2026 paid orders. Use 'unknown' for missing countries.
Result columns · in this order
country_bucketpaid_orderspaid_revenueHow to approach it
Start with paid_orders, then group by the country bucket.
Sample input
| order_id | buyer_id | status | total_amount | country |
|---|---|---|---|---|
| 1001 | 1 | paid | 80 | US |
| 1002 | 3 | paid | 120 | GB |
| 1005 | 2 | paid | 540 | null |
| 1010 | 6 | paid | 640 | GB |
4 rows — all rows shown.
Expected output
| country_bucket | paid_orders | paid_revenue |
|---|---|---|
| GB | 3 | 855 |
| unknown | 1 | 540 |
| US | 1 | 80 |
3 rows — all rows shown.
Constraints
Join orders to customers, keep status = 'paid', use a half-open January range, group by COALESCE(country, 'unknown'), and order by paid_revenue DESC then country_bucket ASC.
Expected skills
Clarifying grain, null behavior, grouped metrics, 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.