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

Keep going