Previous Topic Next topic Print topic


COUNT

ANSI DB2 SQL/DS XDB
X X X X

COUNT is a standard SQL function that counts the number of records in each group satisfying the condition(s) specified. COUNT(*) returns the number of rows in the table.

For all modes except DB2 mode, the formats below return the number of non-NULL values in column-name or expression:

COUNT(column-name)

or:

COUNT(expression)

Allowable formats for all modes appear below:

COUNT(*)

or:

COUNT(DISTINCT expression)

which filters out duplicate values to return the number of distinct values in expression. For example, to discover how many suppliers are currently supplying parts, you could use the query:

SELECT COUNT(DISTINCT sno)
FROM partsupp
Previous Topic Next topic Print topic