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() and PARTITION BY. RANK() OVER (ORDER BY x DESC) numbers rows 1, 2, 3 from the biggest x. PARTITION BY restarts the numbering for each group, so every group gets its own 1. A window can't be filtered in the WHERE of the same query, so rank inside a WITH block and filter outside it.
select customer_name, segment, signup_date, rank() over (partition by segment order by signup_date) as signup_rank from customers
You asked the AI assistant for the best-selling product in each of the 4 categories, by completed revenue. It returned just one row.
AI assistant: “I ranked products by completed revenue and kept the top one per category.”
Run the AI query, then fix it so it returns category, product_name and revenue (2 decimals) for the top product of every category.
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe