Finance Path · Mission 18 of 25Hard

Year-over-year revenue growth

LAG() window function for period-over-period comparison

Back to Finance

The Brief

Mei LinFP&A Managerfpna

Board trend slide. For each revenue account, show year, total revenue, prior-year revenue (LAG), and YoY % change. Columns: `account_name`, `year`, `revenue`, `prior_revenue`, `yoy_pct`. Posted only.

You'll practice

LAG()PARTITION BYYoY

Tables available

fact_transactionsdim_accounts

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

First aggregate revenue by (account_name, year) in a subquery.

Hint 2

Then apply `LAG(revenue) OVER (PARTITION BY account_name ORDER BY year) AS prior_revenue`.

Hint 3

`yoy_pct = (revenue - prior_revenue) / NULLIF(prior_revenue, 0)`. The earliest year per account will have NULL — that's expected.