Documentation

InfluxQL aggregate functions

Use aggregate functions to assess, aggregate, and return values in your data. Aggregate functions return one row containing the aggregate values from each InfluxQL group.

Examples use the sample data set provided in the Get started with InfluxDB tutorial.

COUNT()

Returns the number of non-null field values.

COUNT(field_expression)

Arguments

  • field_expression: Expression to identify one or more fields to operate on. Can be a field key, constant, regular expression, or wildcard (*). Supports all field types.

Examples

Count the number of non-null values in a field

Count the number of non-null values in each field

Count the number of non-null values in fields where the field key matches a regular expression

Count distinct values for a field

Count the number of non-null field values within time windows (grouped by time)

DISTINCT()

Returns the list of unique field values.

DISTINCT(field_key)

Arguments

  • field_key: Field key to return distinct values from. Supports all field types.

Notable behaviors

  • InfluxQL supports nesting DISTINCT() with COUNT().

Examples

List the distinct field values

INTEGRAL()

Returns the area under the curve for queried field values and converts those results into the summed area per unit of time.

  • INTEGRAL() does not support fill().
  • INTEGRAL() supports int64 and float64 field value data types.
INTEGRAL(field_expression[, unit])

Arguments

  • field_expression: Expression to identify one or more fields to operate on. Can be a field key, constant, regular expression, or wildcard (*).
  • unit: Unit of time to use when calculating the integral. Default is 1s (one second).

Examples

Calculate the integral for a field

Calculate the integral for a field and specify the unit option

Calculate the integral for each field and specify the unit option

Calculate the integral for the field keys that matches a regular expression

Calculate the integral for a field grouping by time

MEAN()

Returns the arithmetic mean (average) of field values.

MEAN(field_expression)

Arguments

  • field_expression: Expression to identify one or more fields to operate on. Can be a field key, constant, regular expression, or wildcard (*). Supports numeric fields.

Examples

Calculate the mean value of a field

Calculate the mean value of each field

Calculate the mean value of fields where the field key matches a regular expression

Calculate the mean value of a field within time windows (grouped by time)

MEDIAN()

Returns the middle value from a sorted list of field values.

MEDIAN(field_expression)

Arguments

  • field_expression: Expression to identify one or more fields to operate on. Can be a field key, constant, regular expression, or wildcard (*). Supports numeric fields.

Notable behaviors

  • MEDIAN() is nearly equivalent to PERCENTILE(field_key, 50), except MEDIAN() returns the average of the two middle field values if the field contains an even number of values.

Examples

Calculate the median value of a field

Calculate the median value of each field

Calculate the median value of fields where the field key matches a regular expression

Calculate the median value of a field within time windows (grouped by time)

MODE()

Returns the most frequent value in a list of field values.

MODE(field_expression)

Arguments

  • field_expression: Expression to identify one or more fields to operate on. Can be a field key, constant, regular expression, or wildcard (*). Supports all field types.

Notable behaviors

  • MODE() returns the field value with the earliest timestamp if there’s a tie between two or more values for the maximum number of occurrences.

Examples

Calculate the mode value of a field

Calculate the mode value of each field

Calculate the mode of field keys that match a regular expression

Calculate the mode a field within time windows (grouped by time)

SPREAD()

Returns the difference between the minimum and maximum field values.

SPREAD(field_expression)

Arguments

  • field_expression: Expression to identify one or more fields to operate on. Can be a field key, constant, regular expression, or wildcard (*). Supports numeric fields.

Examples

Calculate the spread of a field

Calculate the spread of each field

Calculate the spread of field keys that match a regular expression

Calculate the spread of a field within time windows (grouped by time)

STDDEV()

Returns the standard deviation of field values.

STDDEV(field_expression)

Arguments

  • field_expression: Expression to identify one or more fields to operate on. Can be a field key, constant, regular expression, or wildcard (*). Supports numeric fields.

Examples

Calculate the standard deviation of a field

Calculate the standard deviation of each field

Calculate the standard deviation of fields where the field key matches a regular expression

Calculate the standard deviation of a field within time windows (grouped by time)

SUM()

Returns the sum of field values.

SUM(field_expression)

Arguments

  • field_expression: Expression to identify one or more fields to operate on. Can be a field key, constant, regular expression, or wildcard (*). Supports numeric fields.

Examples

Calculate the sum of values in a field

Calculate the sum of values in each field

Calculate the sum of values for fields where the field key matches a regular expression

Calculate the sum of values in a field within time windows (grouped by time)


Was this page helpful?

Thank you for your feedback!


New in InfluxDB 3.5

Key enhancements in InfluxDB 3.5 and the InfluxDB 3 Explorer 1.3.

See the Blog Post

InfluxDB 3.5 is now available for both Core and Enterprise, introducing custom plugin repository support, enhanced operational visibility with queryable CLI parameters and manual node management, stronger security controls, and general performance improvements.

InfluxDB 3 Explorer 1.3 brings powerful new capabilities including Dashboards (beta) for saving and organizing your favorite queries, and cache querying for instant access to Last Value and Distinct Value caches—making Explorer a more comprehensive workspace for time series monitoring and analysis.

For more information, check out:

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On November 3, 2025, the latest tag for InfluxDB Docker images will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments.

If using Docker to install and run InfluxDB, the latest tag will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments. For example, if using Docker to run InfluxDB v2, replace the latest version tag with a specific version tag in your Docker pull command–for example:

docker pull influxdb:2