Documentation

InfluxQL selector functions

Use selector functions to assess, select, and return values in your data. Selector functions return one or more rows with the selected 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 IOx storage engine. If a function you need is not here, check the InfluxQL feature support page for more information.

FIRST()

Returns the field value with the oldest timestamp.

FIRST(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 data types.

Notable behaviors

Examples

Select the first value for a field

Select the first value from each field

Select the first value from field keys that match a regular expression

Select the first value from a field within time windows (grouped by time)

LAST()

Returns the field value with the most recent timestamp.

LAST(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 data types.

Notable behaviors

Examples

Select the last value for a field

Select the last value from each field

Select the last value from field keys that match a regular expression

Select the last value from a field within time windows (grouped by time)

MAX()

Returns the greatest field value.

MAX(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

Examples

Select the maximum value from a field

Select the maximum value from each field

Select the maximum value from field keys that match a regular expression

Select the maximum value from a field within time windows (grouped by time)

MIN()

Returns the lowest field value.

MIN(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

Examples

Select the minimum value from a field

Select the minimum value from each field

Select the minimum value from field keys that match a regular expression

Select the minimum value from a field within time windows (grouped by time)

Notable behaviors of selector functions

Timestamps when grouping by time

When using selector functions with a GROUP BY time() clause, most selector functions return the timestamp of the starting boundary for each time interval. However functions with an N argument that specifies the number of results to return per group maintain the original timestamp of each returned point.

Return the start time of each time interval

Was this page helpful?

Thank you for your feedback!


Introducing InfluxDB 3.0

The new core of InfluxDB built with Rust and Apache Arrow. Available today in InfluxDB Cloud Dedicated.

Learn more

State of the InfluxDB Cloud Serverless documentation

The new documentation for InfluxDB Cloud Serverless is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.