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(")"),
)
)| Parameter | Type | Required | Description |
|---|---|---|---|
expr | EXPRESSION | Yes | Expression to count |
over_clause | OVER CLAUSE | Yes | OVER (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