Accumulate values across an ordered window.
Section: Window Function Basics
Compute running total
sql
sql
SELECT order_id, created_at, amount,
SUM(amount) OVER (ORDER BY created_at ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS running_total
FROM orders;Explanation
Running totals are common in finance and time-series analysis.
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 Window Function Basics