Aggregate functions compute a single result from a set of input values.
approx_count_distinct
array_agg
ORDER BY
clause is optional and specifies the order of rows processed in the aggregation, which determines the order of the elements in the result array.
avg
bit_and
bit_or
bool_and
bool_or
count
count(*)
jsonb_agg
ORDER BY
clause is optional and specifies the order of rows processed in the aggregation, which determines the order of the elements in the result array.
jsonb_object_agg
max
min
string_agg
ORDER BY
clause is optional and specifies the order of rows processed in the aggregation, which determines the order of the elements in the result array.
sum
first_value
order_key
is the column or expression used to determine the order of the values. It is required to make the result deterministic.
last_value
stddev_pop
NULL
if the input contains no non-null values.
stddev_samp
NULL
if the input contains fewer than two non-null values.
var_pop
NULL
if the input contains no non-null values.
var_samp
NULL
if the input contains fewer than two non-null values.
mode
sort_expression
: Must be of a sortable type.
This example calculates the mode of the values in column1
from table1
.
percentile_cont
percentile_cont
is not supported for streaming queries yet.fraction
: The fraction value representing the desired percentile. It should be between 0 and 1.
This example calculates the median (50th percentile) of the values in column1
from table1
.
percentile_disc
percentile_disc
is not supported for streaming queries yet.fraction
: The fraction value representing the desired percentile. It should be between 0 and 1.
sort_expression
: Must be of a sortable type.
This example calculates the 75th percentile of the values in column1
from table1
.
approx_percentile
percentile
: The percentile to approximate. It should be between 0 and 1.relative_error
: Optional. Specifies the maximum allowed error in the approximation. Defaults to 0.01 (1%).percentile_column
: The column from which to calculate the percentile. Must be of a numeric type.grouping()
function are not actually evaluated, but they must exactly match expressions given in the GROUP BY
clause of the associated query level.
grouping
GROUP BY
expressions are not included in the current grouping set. Bits are assigned with the rightmost argument corresponding to the least-significant bit; each bit is 0 if the corresponding expression is included in the grouping criteria of the grouping set generating the current result row, and 1 if it is not included.