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(")"),
  )
)
ParameterTypeRequiredDescription
exprEXPRESSIONYesNumeric expression to sum
over_clauseOVER CLAUSEYesOVER (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
Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19