Aggregate
SQL Aggregate Functions
Index
Inverse Distribution Functions
Details
General Aggregate Functions
AVG
Return average (mean) value. If no rows are selected, the result is NULL
. Aggregation are only allowed in select statements.
The data type of result is DOUBLE PRECISION
for TINYINT
, SMALLINT
, INTEGER
, and REAL
arguments, NUMERIC
with additional 10 decimal digits of precision and scale for BIGINT
and NUMERIC
arguments; DECFLOAT
with additional 10 decimal digits of precision for DOUBLE PRECISION
and DECFLOAT
arguments; INTERVAL
with the same leading field precision, all additional smaller datetime units in interval qualifier, and the maximum scale for INTERVAL
arguments.
Examples:
MAX
The highest value. If no rows are selected, the result is NULL
. Aggregate are only allowed in
select statements. The returned value is of the same data type are the parameter.
Examples:
MIN
The lowest value. If no rows are selected, the result is NULL
. Aggregates are only allowed in select statements. The returned value is of the same data type as the parameter.
Examples:
SUM
The sum of all values. If no rows are selected, the result is NULL
.Aggregates are only allowed in select statements.
Examples:
EVERY
Returns true if all expressions are true. If no rows are selected, the result is NULL
. Aggregates are only allowed in select statements.
Examples:
ANY
Returns true if any expression is true. If no rows are selected, the result is NULL
. Aggregates are only allowed in select statements.
Note that if ANY
or SOME
aggregate function is placed on the right side of comparison operation or distinct predicate and argument of this function is a subquery additional parentheses around aggregate function are required, otherwise it will be parsed as quantified predicate.
Examples:
COUNT
TODO
STDDEV_POP
TODO
STDDEV_SAMP
TODO
VAR_POP
TODO
VAR_SAMP
TODO
BIT_AND_AGG
TODO
BIT_OR_AGG
TODO
BIT_XOR_AGG
TODO
BIT_NAND_AGG
TODO
BIT_NOR_AGG
TODO
BIT_XNOR_AGG
TODO
ENVELOPE
TODO
Binary Set Functions
COVAR_POP
TODO
COVAR_SAMP
TODO
CORR
TODO
REGR_SLOPE
TODO
REGR_INTERCEPT
TODO
REGR_COUNT
TODO
REGR_R2
TODO
REGR_AVGX
TODO
REGR_AVGY
TODO
REGR_SXX
TODO
REGR_SYY
TODO
REGR_SXY
TODO
Ordered Aggregate Functions
LISTAGG
TODO
ARRAY_AGG
TODO
Hypothetical Set Functions
RANK aggregate
TODO
DENSE_RANK aggregate
TODO
PERCENT_RANK aggregate
TODO
CUME_DIST aggregate
TODO
Inverse Distribution Functions
PERCENTILE_CONT
TODO
PERCENTILE_DISC
TODO
MEDIAN
TODO
MODE
TODO
JSON Aggregate Functions
JSON_OBJECAGG
TODO
JSON_ARRAYAGG
TODO
Last updated
Was this helpful?