# Aggregate Functions

{% columns %}
{% column %}
{% content-ref url="../../server-usage/stored-routines/stored-functions/stored-aggregate-functions" %}
[stored-aggregate-functions](https://mariadb.com/docs/server/server-usage/stored-routines/stored-functions/stored-aggregate-functions)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Stored Aggregate Functions allow users to create custom aggregate functions that process a sequence of rows and return a single summary result. This page provides a general overview.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/avg" %}
[avg](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/avg)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Calculate the average value. This function computes the arithmetic mean of a numeric expression, ignoring `NULL` values.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/bit\_and" %}
[bit\_and](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/bit_and)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Perform a bitwise `AND` operation. This function returns the result of performing a bitwise `AND` on all values in a given expression.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/bit\_or" %}
[bit\_or](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/bit_or)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Perform a bitwise `OR` operation. This function returns the result of performing a bitwise `OR` on all values in a given expression.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/bit\_xor" %}
[bit\_xor](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/bit_xor)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Perform a bitwise `XOR` operation. This function returns the result of performing a bitwise `XOR` on all values in a given expression.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/count-distinct" %}
[count-distinct](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/count-distinct)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Count unique values. This function returns the number of distinct, non-`NULL` values found in the specified column or expression.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/count" %}
[count](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/count)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Complete `COUNT()` function reference: `COUNT(*`) and `COUNT(expr)` syntax, `COUNT(DISTINCT)` usage, `GROUP BY` aggregation, and `OVER(PARTITION BY)` window syntax.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/group\_concat" %}
[group\_concat](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/group_concat)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Complete `GROUP_CONCAT` reference for MariaDB. Complete function guide with syntax, parameters, return values, and usage examples for production use.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/json\_arrayagg" %}
[json\_arrayagg](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/json_arrayagg)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Aggregate values into a JSON array. This function aggregates a result set column into a single JSON array.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/json\_objectagg" %}
[json\_objectagg](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/json_objectagg)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Aggregate key-value pairs into a JSON object. This function aggregates two columns or expressions into a single JSON object.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/max" %}
[max](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/max)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Find the maximum value. This function returns the highest value in a set of values, applicable to numbers, strings, and dates.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/min" %}
[min](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/min)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Find the minimum value. This function returns the lowest value in a set of values, applicable to numbers, strings, and dates.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/std" %}
[std](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/std)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Calculate population standard deviation. This function returns the square root of the population variance. It is a synonym for `STDDEV_POP()`.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/stddev" %}
[stddev](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/stddev)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Calculate population standard deviation. This function is a synonym for `STD()` and `STDDEV_POP()`, returning the square root of the population variance.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/stddev\_pop" %}
[stddev\_pop](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/stddev_pop)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Calculate population standard deviation. This function computes the standard deviation assuming the set of values represents the entire population.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/stddev\_samp" %}
[stddev\_samp](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/stddev_samp)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Calculate sample standard deviation. This function computes the standard deviation assuming the set of values represents a sample of the population.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/sum" %}
[sum](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/sum)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Calculate the total sum. This function returns the sum of all values in a numeric expression, ignoring `NULL` values.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/var\_pop" %}
[var\_pop](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/var_pop)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Calculate population variance. This function computes the statistical variance for a set of values assumed to be the entire population.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/var\_samp" %}
[var\_samp](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/var_samp)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Calculate sample variance. This function computes the statistical variance for a set of values assumed to be a sample of the population.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="aggregate-functions/variance" %}
[variance](https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions/variance)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Calculate population variance. This function is a synonym for VAR\_POP() and returns the variance of a set of values.
{% endcolumn %}
{% endcolumns %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mariadb.com/docs/server/reference/sql-functions/aggregate-functions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
