AnalystPath

Running Sales Total by Product

SQLMediumMid levelGoldman Sachs~15 min

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_idproduct_idsale_dateamount

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

Related SQL questions