SQLSQL
#46

Compute Cumulative Running Totals with SUM() OVER in SQL

EasyPwC
Interview Question #46
Asked at PwC

Given `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_datedaily_amount
2026-01-011000
2026-01-021500
2026-01-032000
Expected Output Structure3 rows
sale_datedaily_amountrunning_total
2026-01-0110001000
2026-01-0215002500
2026-01-0320004500
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us