Chapter 8 · Window Functions
43. Year-over-Year Account Balance Growth
Hard40 XPFinance
Calculate the year-over-year growth in total account balances opened per year. For each year, compute the total balance of accounts opened that year and the growth rate compared to the previous year. Return the year, yearly_total, prev_year_total, and growth_pct (rounded to 2 decimals). Use LAG window function. Order by year ascending.
Tables
- PKidINT
- FKcustomer_id→ customers.idINT
- account_typeTEXT
- balanceREAL
- currencyTEXT
- opened_atTEXT
- statusTEXT
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.