InfluxQL aggregate functions
Limited availability
InfluxDB Clustered is currently only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.
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.
Missing InfluxQL functions
Some InfluxQL functions are in the process of being rearchitected to work with the InfluxDB 3.0 storage engine. If a function you need is not here, check the InfluxQL feature support page for more information.
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
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()
withCOUNT()
.
Examples
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
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 toPERCENTILE(field_key, 50)
, exceptMEDIAN()
returns the average of the two middle field values if the field contains an even number of values.
Examples
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
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
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.