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.

  1. array_agg

    The PostgreSQL array_agg() function is an aggregate function that returns an array containing all specified values ​​in a group.
  2. avg

    The PostgreSQL avg() function is an aggregate function that computes the average of all specified values ​​in a group and returns it.
  3. bit_and

    The PostgreSQL bit_and() function is an aggregate function that performs a “bitwise AND” operation on all non-null input values.
  4. bit_or

    The PostgreSQL bit_or() function is an aggregate function that performs a “bitwise OR” of all non-null input values.
  5. bit_xor

    The PostgreSQL bit_xor() function is an aggregate function that performs a “bitwise XOR” operation on all non-null input values.
  6. bool_and

    The PostgreSQL bool_and() function is an aggregate function that returns the “logical AND” of all specified non-null Boolean values ​​in a group.
  7. bool_or

    The PostgreSQL bool_or() function is an aggregate function that returns the “logical OR” of all specified non-null Boolean values ​​in a group.
  8. count

    The PostgreSQL count() function is an aggregate function that counts and returns the number of all specified values ​​in a group.
  9. every

    The PostgreSQL every() function is an aggregate function that returns the result of the “logical AND” of all specified non-null Boolean values ​​in a group.
  10. json_agg

    The PostgreSQL json_agg() function is an aggregate function that returns a JSON array containing all the values ​​in a group.
  11. json_object_agg

    The PostgreSQL json_object_agg() function is an aggregate function that returns a JSON object consisting of a set of key-value pairs.
  12. jsonb_agg

    The PostgreSQL jsonb_agg() function is an aggregate function that returns a JSON array containing all the values ​​in a group.
  13. jsonb_object_agg

    The PostgreSQL jsonb_object_agg() function is an aggregate function that returns a JSON object consisting of a set of key-value pairs.
  14. max

    The PostgreSQL max() function is an aggregate function that returns the maximum value of all specified values ​​in a group.
  15. min

    The PostgreSQL min() function is an aggregate function that returns the minimum value of all specified values ​​in a group.
  16. range_agg

    The PostgreSQL range_agg() function is an aggregate function that returns the union of all non-NULL input range values ​​in a group.
  17. range_intersect_agg

    The PostgreSQL range_intersect_agg() function is an aggregate function that returns the intersection of all non-NULL input range values ​​in a group.
  18. stddev

    The PostgreSQL stddev() function is an aggregate function that computes the sample standard deviation of all non-null input values.
  19. stddev_pop

    The PostgreSQL stddev_pop() function is an aggregate function that computes the population standard deviation of all non-null input values.
  20. stddev_samp

    The PostgreSQL stddev_samp() function is an aggregate function that computes the sample standard deviation of all non-null input values.
  21. string_agg

    The PostgreSQL string_agg() function is an aggregate function that returns a string containing all the specified values ​​in a group.
  22. sum

    The PostgreSQL sum() function is an aggregate function that computes the sum of all specified values ​​in a group and returns the result.
  23. var_pop

    The PostgreSQL var_pop() function is an aggregate function that computes the population variance (square of the population standard deviation) for all non-null input values.
  24. var_samp

    The PostgreSQL var_samp() function is an aggregate function that computes the sample variance (square of the sample standard deviation) for all non-null input values.
  25. variance

    The PostgreSQL variance() function is an aggregate function that computes the sample variance (square of the sample standard deviation) for all non-null input values.