Loading exercise…
Loading exercise…
Exercises are built for a keyboard. Read the task here, then open this page on a laptop to solve it.
Window functions: SUM() OVER. A window function adds a value to every row without merging rows. SUM(x) OVER (ORDER BY y) is a running total: each row adds up x for every row up to and including itself. To run a total over monthly sums, build the monthly rows first (a WITH block works), then put the window on top.
select month, revenue_target, sum(revenue_target) over (order by month) as target_ytd from targets where region_id = 1 order by month
The CFO wants a year-to-date view: for each month, that month's revenue and the total from January up to that month.
Return month (1 to 12), revenue for that month and revenue_ytd (the running total up to and including that month), both 2 decimals, completed orders only, January first.
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe