8
votes

I have pretty simple measurement in influxDB and have default time column and two other columns as shown below,

Select * from measurement

gives me this out put.

time                            component_id    jkey
2016-09-27T02:49:17.837587671Z      3   "timestamp"
2016-09-27T02:49:17.849447239Z      3   "init_time"
2016-09-27T02:49:17.885999439Z      3   "ae_name"
2016-09-27T02:49:17.893056849Z      3   "init_time"

How can i select the last record of this measurement? The record which have maximum time value.

1

1 Answers

14
votes

This can be done with last(). See the docs for more information: link. Or take a look at this example from the docs.

SELECT LAST("water_level") FROM "h2o_feet" WHERE "location" = 'santa_monica'

This will return the "newest" entry.