COUNT( )

From InterBase
Jump to: navigation, search

Go Up to Statement and Function Reference (Language Reference Guide)


Calculates the number of rows that satisfy search condition of a query. Available in gpre, DSQL, and isql.

 COUNT ( * | [ALL] value | DISTINCT value)
Argument Description

Retrieves the number of rows in a specified table, including NULL values

ALL

Counts all non-NULL values in a column.

DISTINCT

Returns the number of unique, non-NULL values for the column.

<val>

A column or expression.

Description: COUNT() is an aggregate function that returns the number of rows that satisfy the search condition of a query. It can be used in views and joins, as well as in tables.

Example: The following embedded SQL statement returns the number of unique currency values it encounters in the COUNTRY table:

EXEC SQL
SELECT COUNT (DISTINCT CURRENCY) INTO :cnt FROM COUNTRY;

See Also