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 buyer_id, paid_revenue, and buyer_rank for buyers whose rank is at most 3.
Result columns · in this order
buyer_idpaid_revenuebuyer_rankHow to approach it
Compute buyer_revenue, rank it, then filter the ranked result.
Sample input
| buyer_id | paid_orders |
|---|---|
| 2 | 540 + 110 |
| 6 | 640 |
| 3 | 120 + 95 |
| 1 | 80 |
4 rows — all rows shown.
Expected output
| buyer_id | paid_revenue | buyer_rank |
|---|---|---|
| 2 | 650 | 1 |
| 6 | 640 | 2 |
| 3 | 215 | 3 |
3 rows — all rows shown.
Constraints
Aggregate paid revenue per buyer first. Use RANK() ordered by paid_revenue DESC, then filter buyer_rank <= 3 and order by buyer_rank, buyer_id.
Expected skills
Tie-aware ranking and ranking after aggregation.
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.