COUNT

Returns the number of items in a group. COUNT works like the COUNT_BIG function. The only difference between the two functions is their return values. COUNT always returns an int data type value. COUNT_BIG always returns a bigint data type value.

Syntax

COUNT ( { [ [ ALL | DISTINCT ] expression ] | * } )
    [ OVER (
        [ partition_by_clause ]
        [ order_by_clause ]
        [ ROW_or_RANGE_clause ]
    ) ]

Arguments

expression

Is an expression of any type except text, image, or ntext. Aggregate functions and subqueries are not permitted.

Return types

int

Example

SELECT COUNT([FloatValue]) OVER (PARTITION BY [IdNullable] ORDER BY [IntValue]) AS [CountOver]
  FROM [BasicDataTable]

See Also