Problem Statement
Which frame reliably produces a cumulative running total from the first row to the current row?
Explanation
UNBOUNDED PRECEDING to CURRENT ROW sums all rows from the start of the partition through the current one. It is the standard running total frame.
Be explicit about ROWS to avoid surprises with peer groups under RANGE semantics.
Code Solution
SolutionRead Only
SUM(amount) OVER ( PARTITION BY account_id ORDER BY txn_time, id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW ) AS running_balance
