Aggregate Functions
Aggregate functions compute aggregated results from zero or more input values and have the form
<name> ( [ all | distinct ] <expr> ) [ where <pred> ]
where
<name>is an identifier naming the function,allanddistinctare optional keywords,<expr>is any expression that is type compatible with the particular function, and<pred>is an optional Boolean expression that filters inputs to the function.
Aggregate functions may appear in
- the aggregate operator,
- an aggregate shortcut, or
- in SQL operators when performing aggregations.
When aggregate functions appear in context of grouping
(e.g., the by clause of an aggregate operator or a
SQL operator with a GROUP BY clause),
then the aggregate function produces one output value for each
unique combination of grouping expressions.
If the case-insensitive distinct option is present, then the inputs
to the aggregate function are filtered to unique values for each
unique grouping.
If the case-insensitive all option is present, then all values
for each unique group are passed as input to the aggregate function.
Calling an aggregate function in a pipe-operator expression outside of an aggregating context is an error.