SQL interview question: Running Total

Daily Running Total of Sales

Finance needs a report showing cumulative daily revenue to track toward quarterly goals.

Calculate a running total where each day shows the sum of all sales up to and including that day.

Return sale_date, daily_revenue, and running_total. Order by sale_date.

Skills: SUM() window function with ORDER BY

Tables

daily_sales 15 rows
  • sale_date text PK
  • daily_revenue real
sale_datedaily_revenue
2025-01-011000.0
2025-01-021200.0
2025-01-03900.0
About the e-commerce sample database

Practice on your iPhone

Query Dojo for iPhone has 85 interview questions, timed mock interviews and a tile builder, so you can write queries without a keyboard.

Get the app

Keep going