Generate a running total
SQL
Medium
2 views
Problem Description
For Orders sorted by order_date, show running sum of total_amount.
Sample Test Case
Input:
Orders(order_date, total_amount)
Constraints
Use window SUM
Official Solution
SELECT order_id, order_date, total_amount, SUM(total_amount) OVER (ORDER BY order_date, order_id) AS running_total FROM Orders;
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!