Reputation: 59
I am working on InfluxDb and have a time series data which records temperature of a location. Here i have to find the max temp and the time stamp for each day.
The task is to:
I have wrote a query but I'am not getting the output as required.
SELECT MAX(mean)
FROM (SELECT mean("value")
FROM "temperature"
WHERE ("location" = 'L1')
GROUP BY time(1h))
GROUP BY time(1d)
I'am getting the output as:
time max
---- ---
2020-01-17T00:00:00Z 573.44
2020-01-16T00:00:00Z 674.44
Here am getting the time stamp as 00:00:00z is there a way to get the exact time i.e if mean temp is 573.44 at 13:00 hour on 2020-01-17, The timestamp should be 2020-01-17T13:00:00Z
Upvotes: 0
Views: 335
Reputation: 2607
GROUP BY
effectively removes per-entry timestamps. It's like all the data for the grouping interval (e.g. for the day) gets dropped into a bucket without their timestamps. The bucket has a single timestamp - the start of the interval.
The result only ever has the timestamp of the start of the GROUP BY
interval.
The only way to do this is in the app, not the backend. You might want to experiment; if you only need resolution down to the e.g. nearest 5 minutes, do the query using GROUP BY time(5m)
. This can be done to shrink the size of data retrieved by the client vs backend processing time.
Upvotes: 0