Loading exercise…
Loading exercise…
Exercises are built for a keyboard. Read the task here, then open this page on a laptop to solve it.
NTILE(). NTILE(n) OVER (ORDER BY x) deals the rows into n groups of (nearly) equal size, numbered 1 to n in x order. When the rows don't divide evenly, the first groups get one extra row. Give the ORDER BY a tie-break so the split is the same on every run.
select product_name, list_price, ntile(3) over (order by list_price desc, product_name) as price_band from products
Finance wants to see how concentrated revenue is: split the buying customers into four equal groups by 2025 spend and show what each group brings in.
Split every customer with a completed order into 4 quartiles by total completed revenue (quartile 1 = highest spenders; on equal totals the lower customer_id goes first). Return quartile, customers (how many are in it) and revenue (their combined total, 2 decimals).
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe