SUM() OVER ...
All functions > WINDOW FUNCTION > SUM() OVER ...
Returns the sum of values in the window frame.
Syntax
Diagram(
Sequence(
Terminal("SUM"),
Terminal("("),NonTerminal('expr'),Terminal(")"),
Terminal("OVER"),
Terminal("("),
NonTerminal("over_clause"),
Terminal(")"),
)
)| Parameter | Type | Required | Description |
|---|---|---|---|
expr | EXPRESSION | Yes | Numeric expression to sum |
over_clause | OVER CLAUSE | Yes | OVER (PARTITION BY ... ORDER BY ... [FRAME ...]) |
Notes
- Calculates sum over a window of rows
- PARTITION BY divides rows into independent groups
- ORDER BY determines row ordering within partitions
- Window frame controls which rows are included in the sum
- Default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
- Useful for running totals and cumulative sums
- Returns same type as input expression
- NULL values are ignored in the calculation