Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select last record in InfluxDB

Tags:

influxdb

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.

like image 562
Ammad Avatar asked Sep 30 '16 23:09

Ammad


1 Answers

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.

like image 101
IIIIIIIIIIIIIIIIIIIIII Avatar answered Nov 16 '22 05:11

IIIIIIIIIIIIIIIIIIIIII