Running Sales Total by Product
Problem
**[Asked at Goldman Sachs]**
For each product, calculate the **running (cumulative) total** of sales
ordered by sale date.
Return `product_id`, `sale_date`, `amount`, and `running_total`,
ordered by product then date.
Tables
Example rows — the live problem includes the full dataset.
sales
| sale_id | product_id | sale_date | amount |
|---|
Expected output
Your answer should return 5 rows with the columns product_id, sale_date, amount, running_total.
Starter code (SQL)
SELECT *
FROM sales;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock