Hello. I’ve been playing with influx for the last week but I have been unable to make sure when I’m doing aggregations I get a value in the current time instead of getting values based on the presets.
This is my starting query:
SELECT time, mean(value) from temperature where time >= ‘2019-11-03’ and time <= ‘2019-11-06T02:51:18Z’ group by time(5h) order by time desc
If I change that query with the following, I get the desired result, which is getting a data point now, and not data points in the presets.
SELECT time, mean(value) from temperature where time >= ‘2019-11-03’ and time <= ‘2019-11-06T02:51:18Z’ group by time(5h, -189m) order by time desc
desired top timestamp in top result:
(Im aware that the aggregation might be a null because influx does aggregation after the timestamp and not before)
My question is how to calculate the -189 value (Is this possible with the date ranges and the ‘bucket’ time range, in this case 5h?). I’ve been trying many things with the date ranges, modulo and such but haven’t been able to get what I’m looking for.
If it helps I’ve used this as reference.
I also found this which looked like I could have used last() to achieve what I was looking for, but I tried and it threw and error saying that only now() was supported