Loading exercise…
Loading exercise…
Exercises are built for a keyboard. Read the task here, then open this page on a laptop to solve it.
RANK() vs DENSE_RANK(). Both give tied rows the same number. RANK() then skips ahead (1, 2, 2, 4), like a race result. DENSE_RANK() doesn't skip (1, 2, 2, 3), which suits tiers and levels. ROW_NUMBER() never ties at all. After a GROUP BY, you can rank on an aggregate directly: RANK() OVER (ORDER BY COUNT(*) DESC).
select category, count(*) as products, dense_rank() over (order by count(*) desc) as size_rank from products group by category
For the East loyalty tiers, Priya Raman wants customers ranked by how many completed orders they placed. Tied customers share a tier and the next tier follows straight on.
Return customer_name, orders (number of completed orders) and order_rank for every East customer (region_id 3) with a completed order. Most orders is rank 1; tied customers share a rank and the next rank has no gap (1, 2, 2, 3).
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe