Query first and last values
By default, InfluxDB returns results sorted by time, however you can use the to change how results are sorted. and last()
respect the sort order of input data and return records based on the order they are received in.
returns the first non-null record in an input table.
Given the following input:
_time | _value |
---|---|
2020-01-01T00:01:00Z | 1.0 |
last
last()
returns the last non-null record in an input table.
Given the following input:
The following function returns:
_time | _value |
---|---|
2020-01-01T00:04:00Z | 3.0 |
Given the following input:
The following function returns:
_time | _value |
---|---|
2020-01-01T00:00:59Z | 10 |
2020-01-01T00:01:59Z | 9 |
2020-01-01T00:02:59Z | 11 |