SQL
All Top 50 SQL Interview Questions#46
Compute Cumulative Running Totals with SUM() OVER in SQL
EasyPwCInterview Question #46
Asked at PwCGiven `daily_sales` (sale_date, daily_amount), write a SQL query to calculate the cumulative running total of revenue up to each day.
Input Table: daily_sales
3 rows preview| sale_date | daily_amount |
|---|---|
| 2026-01-01 | 1000 |
| 2026-01-02 | 1500 |
| 2026-01-03 | 2000 |
Expected Output Structure3 rows
| sale_date | daily_amount | running_total |
|---|---|---|
| 2026-01-01 | 1000 | 1000 |
| 2026-01-02 | 1500 | 2500 |
| 2026-01-03 | 2000 | 4500 |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.