COUNT (SQL)
A window function that assigns a number to each row in the specified window frame starting at 1.
Synopsis
COUNT(*|field)
Description
COUNT creates a counter starting at one for each row (or specific rows if the field argument is specified).
This window function works analogously to the aggregate function COUNT.
Arguments
field
Specifies which field the count should be incremented in. If field is specified, the count is only incremented if the contents of field is non-null. Otherwise, the count is incremented with every row.
Examples
The following example counts the number of employees in each department while leaving each employee as their own individual row:
SELECT COUNT(Employee) OVER (PARTITION BY Department) FROM Company.Employee
See Also
-
Aggregate functions: COUNT