COUNT()
Counts non-NULL
values
BIGINT
COUNT ([ALL | DISTINCT] <expr> | *)
Parameter | Description |
---|---|
expr |
Expression.It may contain a table column, a constant, a variable, an expression, a non-aggregate function or a UDF that returns a numeric data type.Aggregate functions are not allowed as expressions |
COUNT
returns the number of non-null values in a group.
ALL
is the default: it counts all values in the set that are not NULL
.
If DISTINCT
is specified, duplicates are excluded from the counted set.
If COUNT (*)
is specified instead of the expression expr, all rows will be counted.COUNT (*)
—
does not accept parameters
cannot be used with the keyword DISTINCT
does not take an expr argument, since its context is column-unspecific by definition
counts each row separately and returns the number of rows in the specified table or group without omitting duplicate rows
counts rows containing NULL
If the result set is empty or contains only NULL
in the specified column(s), the returned count is zero.