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_date | daily_revenue |
|---|---|
| 2025-01-01 | 1000.0 |
| 2025-01-02 | 1200.0 |
| 2025-01-03 | 900.0 |