COUNT() OVER ...

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

Returns the count of rows in the window frame.

Syntax

Diagram(
  Sequence(
    Terminal("COUNT"),
    Terminal("("),NonTerminal('expr'),Terminal(")"),
    Terminal("OVER"),
    Terminal("("),
    NonTerminal("over_clause"),
    Terminal(")"),
  )
)
ParameterTypeRequiredDescription
exprEXPRESSIONYesExpression to count
over_clauseOVER CLAUSEYesOVER (PARTITION BY ... ORDER BY ... [FRAME ...])

Notes

  • Counts rows over a window
  • PARTITION BY divides rows into independent groups
  • ORDER BY determines row ordering within partitions
  • Window frame controls which rows are included in the count
  • Default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
  • NULL values in the expression are excluded from the count
  • Always returns BIGINT type
  • Useful for running counts and row numbering within windows
Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19