Loading exercise…
Loading exercise…
Exercises are built for a keyboard. Read the task here, then open this page on a laptop to solve it.
AVG() OVER (PARTITION BY). GROUP BY folds rows into one per group. A window function keeps every row and adds a group value to it: AVG(x) OVER (PARTITION BY g) puts the average of x for the row's group g on each row. No GROUP BY needed. COUNT, SUM, MIN and MAX work the same way.
select customer_name, segment, count(*) over (partition by segment) as customers_in_segment from customers
Purchasing is reviewing price points and wants every product listed beside the average list price of its category.
Return product_name, category, list_price and category_avg_price (the average list_price of that product's category, 2 decimals), one row per product.
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe