I want to know when the latest data point is for each value of some other field, and how old it is. Here’s the query I wrote:
select now() - time, last("temperature") from temps group by location;
But I get
ERR: undefined function now()
which seems odd because I can use that expression in the “where” clause:
select last("temperature") from temps where time < now() - 60m group by location;
For what it’s worth, it doesn’t work any better if I apply an aggregate function to time, as follows:
select now() - time, last("temperature") from temps group by location;
I wonder
(a) Why can’t it simply calculate now() - time for each row in the result? But more importantly
(b) Is there another way to reach my goal, to get the age of the latest data points after grouping?