Loading exercise…
Loading exercise…
Exercises are built for a keyboard. Read the task here, then open this page on a laptop to solve it.
LAG(). LAG(x) OVER (ORDER BY y) returns x from the row before, in y order; the first row gets NULL. LEAD(x) looks at the row after, and LAG(x, 2) goes back two rows. Build one row per period first (a WITH block works), then put LAG on top.
select month, revenue_target, lag(revenue_target) over (order by month) as prev_target from targets where region_id = 2 order by month
The CFO's monthly pack shows each month's completed revenue beside the month before, so the change is easy to read.
Return month (1 to 12), revenue and prev_revenue (the previous month's revenue, empty for January), both 2 decimals, completed orders only.
Loading the Brightline dataset…
Language
Full plan
SQL ✓ · Excel and Power BI also included
Cancel anytime · 14-day full refund · Secure payment by Stripe