PostgreSQL Aggregate Functions
PostgreSQL aggregate functions are mainly used for data statistics, such as count, sum, average, etc. Aggregate functions combined with grouping operations allow you to count data in more dimensions.
-
array_agg
The PostgreSQLarray_agg()
function is an aggregate function that returns an array containing all specified values in a group. -
avg
The PostgreSQLavg()
function is an aggregate function that computes the average of all specified values in a group and returns it. -
bit_and
The PostgreSQLbit_and()
function is an aggregate function that performs a “bitwise AND” operation on all non-null input values. -
bit_or
The PostgreSQLbit_or()
function is an aggregate function that performs a “bitwise OR” of all non-null input values. -
bit_xor
The PostgreSQLbit_xor()
function is an aggregate function that performs a “bitwise XOR” operation on all non-null input values. -
bool_and
The PostgreSQLbool_and()
function is an aggregate function that returns the “logical AND” of all specified non-null Boolean values in a group. -
bool_or
The PostgreSQLbool_or()
function is an aggregate function that returns the “logical OR” of all specified non-null Boolean values in a group. -
count
The PostgreSQLcount()
function is an aggregate function that counts and returns the number of all specified values in a group. -
every
The PostgreSQLevery()
function is an aggregate function that returns the result of the “logical AND” of all specified non-null Boolean values in a group. -
json_agg
The PostgreSQLjson_agg()
function is an aggregate function that returns a JSON array containing all the values in a group. -
json_object_agg
The PostgreSQLjson_object_agg()
function is an aggregate function that returns a JSON object consisting of a set of key-value pairs. -
jsonb_agg
The PostgreSQLjsonb_agg()
function is an aggregate function that returns a JSON array containing all the values in a group. -
jsonb_object_agg
The PostgreSQLjsonb_object_agg()
function is an aggregate function that returns a JSON object consisting of a set of key-value pairs. -
max
The PostgreSQLmax()
function is an aggregate function that returns the maximum value of all specified values in a group. -
min
The PostgreSQLmin()
function is an aggregate function that returns the minimum value of all specified values in a group. -
range_agg
The PostgreSQLrange_agg()
function is an aggregate function that returns the union of all non-NULL input range values in a group. -
range_intersect_agg
The PostgreSQLrange_intersect_agg()
function is an aggregate function that returns the intersection of all non-NULL input range values in a group. -
stddev
The PostgreSQLstddev()
function is an aggregate function that computes the sample standard deviation of all non-null input values. -
stddev_pop
The PostgreSQLstddev_pop()
function is an aggregate function that computes the population standard deviation of all non-null input values. -
stddev_samp
The PostgreSQLstddev_samp()
function is an aggregate function that computes the sample standard deviation of all non-null input values. -
string_agg
The PostgreSQLstring_agg()
function is an aggregate function that returns a string containing all the specified values in a group. -
sum
The PostgreSQLsum()
function is an aggregate function that computes the sum of all specified values in a group and returns the result. -
var_pop
The PostgreSQLvar_pop()
function is an aggregate function that computes the population variance (square of the population standard deviation) for all non-null input values. -
var_samp
The PostgreSQLvar_samp()
function is an aggregate function that computes the sample variance (square of the sample standard deviation) for all non-null input values. -
variance
The PostgreSQLvariance()
function is an aggregate function that computes the sample variance (square of the sample standard deviation) for all non-null input values.