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 query_id, query_label, gb_scanned, and cost_rank for the three queries that scanned the most data.
Result columns · in this order
query_idquery_labelgb_scannedcost_rankHow to approach it
Rank the runs by gb_scanned descending, then keep the top three.
Sample input
| query_id | query_label | gb_scanned |
|---|---|---|
| 1 | daily_active_users | 12 |
| 2 | orders_export | 240 |
| 3 | revenue_by_country | 3 |
| 4 | event_funnel | 85 |
| 5 | late_event_audit | 6 |
| 6 | adhoc_select_star | 180 |
6 rows — all rows shown.
Expected output
| query_id | query_label | gb_scanned | cost_rank |
|---|---|---|---|
| 2 | orders_export | 240 | 1 |
| 6 | adhoc_select_star | 180 | 2 |
| 4 | event_funnel | 85 | 3 |
3 rows — all rows shown.
Constraints
Use RANK() OVER (ORDER BY gb_scanned DESC) as cost_rank. Order by gb_scanned DESC, query_id ASC, and keep the top 3.
Expected skills
Ranking query history by cost and selecting optimization targets.
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.