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.
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.
BOTTOM()
Returns the smallest Nfield values.
BOTTOM() supports int64 and float64 field value data types.
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.
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.
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.
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.
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.
N: Percentile to return.
Must be an integer or float value greater than 0 and less than or equal to 100.
PERCENTILE(example_field, 50) is nearly equivalent to
MEDIAN(example_field),
except MEDIAN() returns the average of the two middle values if the field
contains an even number of values.
PERCENTILE(example_field, 0) returns null.
Examples
Select the 50th percentile value from a field
SELECTPERCENTILE(temp,50)FROMhome
name: home
time
percentile
2022-01-01T11:00:00Z
22.4
Select the 50th percentile value from each field
SELECTPERCENTILE(*,50)FROMhome
name: home
time
percentile_co
percentile_hum
percentile_temp
1970-01-01T00:00:00Z
1
36
22.4
Select the 50th percentile value from field keys that match a regular expression
SELECTPERCENTILE(/^[th]/,50)FROMhome
name: home
time
percentile_hum
percentile_temp
1970-01-01T00:00:00Z
36
22.4
Select the 50th percentile value from a field within time windows (grouped 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.
If the InfluxQL group or specified tag key contains X points or unique tag
values and X is less than N, the function returns X results instead of N
for each group or tag value.
View example for FN(field_key, N)
The example below selects the bottom 5 temperatures from the Kitchen between
2022-01-01T08:00:00Z
and 2022-01-01T10:00:00Z.
There are only 3 points recorded for the Kitchen during the queried time range,
so the query returns 3 points instead of 5.
The example below selects the top temperature from 3 unique values of the room tag.
However, the room tag only has 2 unique values, so results only contain 2 values.
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:
InfluxDB v3 enhancements and InfluxDB Clustered is now generally available
New capabilities, including faster query performance and management
tooling advance the InfluxDB v3 product line.
InfluxDB Clustered is now generally available.
InfluxDB v3 performance and features
The InfluxDB v3 product line has seen significant enhancements in query
performance and has made new management tooling available. These enhancements
include an operational dashboard to monitor the health of your InfluxDB cluster,
single sign-on (SSO) support in InfluxDB Cloud Dedicated, and new management
APIs for tokens and databases.