General-Purpose Aggregate Functions
- 4">
+ 5">
|
Function
Argument Type(s)
Return Type
+ Partial Mode
Description
array of the argument type
+ No
input values, including nulls, concatenated into an array
same as argument data type
+ No
input arrays concatenated into array of one higher dimension
(inputs must all have same dimensionality,
and cannot be empty or NULL)
double precision for a floating-point argument,
otherwise the same as the argument data type
+ All types apart from floating-point types
the average (arithmetic mean) of all input values
same as argument data type
+ Yes
the bitwise AND of all non-null input values, or null if none
same as argument data type
+ Yes
the bitwise OR of all non-null input values, or null if none
bool
+ Yes
true if all input values are true, otherwise false
bool
+ Yes
true if at least one input value is true, otherwise false
bigint
+ Yes
number of input rows
count(expression)
any
bigint
+ Yes
number of input rows for which the value of
class="parameter">expression is not null
bool
+ Yes
equivalent to bool_and
json
+ No
aggregates values as a JSON array
jsonb
+ No
aggregates values as a JSON array
json
+ No
aggregates name/value pairs as a JSON object
jsonb
+ No
aggregates name/value pairs as a JSON object
any numeric, string, date/time, network, or enum type,
or arrays of these types
same as argument type
+ Yes
maximum value of
class="parameter">expression across all input
any numeric, string, date/time, network, or enum type,
or arrays of these types
same as argument type
+ Yes
minimum value of
class="parameter">expression across all input
same as argument types
+ No
input values concatenated into a string, separated by delimiter
bigint arguments, otherwise the same as the
argument data type
+ All types apart from floating-point types
sum of expression across all input values
xml
+ No
concatenation of XML values (see also )
substitute zero or an empty array for null when necessary.
+ Aggregate functions which support Partial Mode
+ are eligible to participate in various optimizations, such as parallel
+ aggregation.
+
+
Aggregate Functions for Statistics
- 4">
+ 5">
|
Function
Argument Type
Return Type
+ Partial Mode
Description
double precision
+ No
correlation coefficient
double precision
+ No
population covariance
double precision
+ No
sample covariance
double precision
+ No
average of the independent variable
(sum(X)/N)
double precision
+ No
average of the dependent variable
(sum(Y)/N)
bigint
+ No
number of input rows in which both expressions are nonnull
double precision
+ No
y-intercept of the least-squares-fit linear equation
determined by the (
class="parameter">X,
double precision
+ No
square of the correlation coefficient
double precision
+ No
slope of the least-squares-fit linear equation determined
by the (X,
Y) pairs
double precision
+ No
sum(
class="parameter">X^2) - sum(
class="parameter">X)^2/
double precision
+ No
sum(
class="parameter">X*
class="parameter">Y) - sum(
double precision
+ No
sum(
class="parameter">Y^2) - sum(
class="parameter">Y)^2/
double precision for floating-point arguments,
otherwise numeric
+ All types apart from floating-point types
historical alias for stddev_samp
double precision for floating-point arguments,
otherwise numeric
+ All types apart from floating-point types
population standard deviation of the input values
double precision for floating-point arguments,
otherwise numeric
+ All types apart from floating-point types
sample standard deviation of the input values
double precision for floating-point arguments,
otherwise numeric
+ All types apart from floating-point types
historical alias for var_samp
double precision for floating-point arguments,
otherwise numeric
+ All types apart from floating-point types
population variance of the input values (square of the population standard deviation)
double precision for floating-point arguments,
otherwise numeric
+ All types apart from floating-point types
sample variance of the input values (square of the sample standard deviation)
Ordered-Set Aggregate Functions
- 5">
+ 6">
|
Function
Direct Argument Type(s)
Aggregated Argument Type(s)
Return Type
+ Partial Mode
Description
same as sort expression
+ No
returns the most frequent input value (arbitrarily choosing the first
one if there are multiple equally-frequent results)
same as sort expression
+ No
continuous percentile: returns a value corresponding to the specified
fraction in the ordering, interpolating between adjacent input items if
array of sort expression's type
+ No
multiple continuous percentile: returns an array of results matching
the shape of the fractions parameter, with each
same as sort expression
+ No
discrete percentile: returns the first input value whose position in
the ordering equals or exceeds the specified fraction
array of sort expression's type
+ No
multiple discrete percentile: returns an array of results matching the
shape of the fractions parameter, with each non-null
Hypothetical-Set Aggregate Functions
- 5">
+ 6">
|
Function
Direct Argument Type(s)
Aggregated Argument Type(s)
Return Type
+ Partial Mode
Description
bigint
+ No
rank of the hypothetical row, with gaps for duplicate rows
bigint
+ No
rank of the hypothetical row, without gaps
double precision
+ No
relative rank of the hypothetical row, ranging from 0 to 1
double precision
+ No
relative rank of the hypothetical row, ranging from
1/N> to 1