SQL 2023 · Aggregation and window functions
Compute a running total
Add up amounts in date order.
SELECT day, amount, SUM(amount) OVER (ORDER BY day) AS running_total FROM sales;
Official SQL 2023 documentation
More aggregation and window functions commands
- Count rows
- Group and total
- Filter groups
- Number rows within groups
- Rank rows
- Compare with the previous row
All aggregation and window functions commands · SQL 2023 cheatsheet