AVG() OVER ...

All functions > WINDOW FUNCTION > AVG() OVER ...

Returns the average of values in the window frame.

Syntax

Diagram(
  Sequence(
    Terminal("AVG"),
    Terminal("("),NonTerminal('expr'),Terminal(")"),
    Terminal("OVER"),
    Terminal("("),
    NonTerminal("over_clause"),
    Terminal(")"),
  )
)
ParameterTypeRequiredDescription
exprEXPRESSIONYesNumeric expression to average
over_clauseOVER CLAUSEYesOVER (PARTITION BY ... ORDER BY ... [FRAME ...])

Notes

  • Calculates average 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 average
  • Default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
  • Useful for moving averages and rolling means
  • 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