Chapter 7 · CTEs
16. Month-over-Month Transaction Growth Rate
Hard40 XPFinance
Compute the month-over-month growth rate of total transaction amounts. CTE: aggregate total amount per month. Main query: use LAG to get the previous month's total, then compute growth_rate as (current - previous) / previous * 100, rounded to 1 decimal. Sort by month.
Tables
- PKidINT
- FKaccount_id→ accounts.idINT
- transaction_dateTEXT
- typeTEXT
- amountREAL
- balance_afterREAL
- descriptionTEXT
- reference_numberTEXT
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.