COUNT function [Aggregate]

Function

Counts the number of rows in a group, depending on the specified parameters.

Syntax

COUNT ( *  |  expression  |  DISTINCT column-name  )

Parameters

* Returns the number of rows in each group.

expression Returns the number of rows in each group where expression is not the NULL value.

DISTINCT column-name Returns the number of different values in column-name. Rows where the value is the NULL value are not included in the count.

Example

The following statement returns each unique city, and the number of rows with that city value:

SELECT city , Count(*)
FROM employee
GROUP BY city

Standards and compatibility

See also

“AVG function [Aggregate]”

“SUM function [Aggregate]”

Chapter 4, “Using OLAP” in the Sybase IQ Performance and Tuning Guide