<< Click to Display Table of Contents >> Navigation: Apollo SQL > Aggregate Functions > COUNT |
Counts the number of rows retrieved by a SELECT statement.
Syntax:
COUNT(* | [ALL] column_reference | DISTINCT column_reference)
AS column
The SELECT statement may be a single- or multi-table query. The value returned by COUNT reflects a reduced row count produced by a filtered dataset.
Examples:
SELECT COUNT(amount) AS amt FROM averaging
SELECT COUNT(*) AS InCalifornia FROM cust WHERE state = 'CA'
ALL returns the count for all rows. When DISTINCT is not specified, ALL is the implied default.
DISTINCT ignores duplicate values in the specified column when counting rows.