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:00Z1.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:00Z3.0

    Given the following input:

    The following function returns:

    last

    _time_value
    2020-01-01T00:00:59Z10
    2020-01-01T00:01:59Z9
    2020-01-01T00:02:59Z11