SQL QuestSQL Interview Questions › Subqueries & CTEs

Month-over-Month Volume Growth

HardProQuerying BasicsSubqueries & CTEsWindow FunctionsNULL Handling

Growth is a window question: this month against the month before. Sum the amount_gbp of completed transactions per month (strftime('%Y-%m', ts)), then use LAG to bring the previous month alongside.

Return month, volume_gbp (rounded to 2 decimals), prev_volume_gbp and growth_pct (100.0 * (volume - previous) / previous, rounded to 1 decimal). The first month has no previous month: its prev_volume_gbp and growth_pct are NULL, not 0. Order by month ascending.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

transactions

txn_iduser_idtstypeamountcurrencyamount_gbpfee_gbpmerchant_categorymerchant_countrycounterparty_user_idstatusdecline_reason
112025-06-14 11:01:51fx_exchange32271.15JPY167.811.68NULLNULLNULLcompletedNULL
212025-06-14 11:17:45bill_payment59.53EUR50.60utilitiesIENULLcompletedNULL
372025-06-16 10:06:38card_payment122.27EUR103.930shoppingESNULLcompletedNULL

Expected output: month=2025-06, volume_gbp=3745.51, prev_volume_gbp=NULL, growth_pct=NULL; month=2025-07, ... growth_pct=18.6 ...

Hint

This is a Pro challenge — the hint, the step-by-step tutor and the reference solution open in the app.

Concepts

SELECT CTE Window Functions LAG strftime NULL Handling

Practise the topic: SQL practice questions · CTE practice · Window function practice · NULL handling practice · Advanced SQL interview questions

In these company practice sets

Revolut

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Cumulative Distinct Customers Over TimeHard · FreeRunning Total RevenueHard · FreeYear-over-Year GrowthHard · Free7-Day Rolling Revenue AverageHard · FreeMulti-CTE Revenue PipelineHard · FreeWealthy Survivor ProfileHard · Pro

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test