Cumulative sum ordered by date.
Section: Running metrics
Running total
sql
sql
SELECT order_date,
amount,
SUM(amount) OVER (
ORDER BY order_date
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS running_total
FROM daily_sales;Explanation
Always specify the frame explicitly when you want a deterministic row-by-row cumulative total.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Running metrics