Running totals
SQL Running Total Interview Questions
A running total carries a number forward as the rows advance: cumulative revenue, month-on-month change, a moving average. Growth and retention reporting is built almost entirely out of them.
What running total questions ask you to do
Across the questions here, these are the shapes that come up:
- Build a cumulative total over time
- Compare each period with the one before it
- Work out a moving average over a fixed number of rows
- Track a balance down an ordered ledger
- Show progress as a share of the final total
Common mistakes with running totals
Leaving the frame unstated is the usual error. Given an order and nothing else, SQL treats every row sharing the same date as one step and gives them all the same total, so a whole day’s revenue appears against each of that day’s orders. Saying explicitly that the total runs from the beginning to the current row fixes it.
Questions to practice
- Listening time so farSQL
Spotifymedium - Money moved so farSQLPremium
PhonePemedium - Position after each tradeSQL
Zerodhamedium - Refunds so farSQLPremium
Flipkartmedium - Revenue against targetSQLPremium
Swiggymedium - Revenue to date per merchantSQL
Shopifymedium - Running account balancePandasPremium
Stripemedium - Spend to dateSQLPremium
Nykaamedium - Drawdown from the peakSQL
Coinbasehard - The day the position closedSQLPremium
Zerodhahard
Questions last reviewed 19 October 2026.