Store max value if bigger than old max

Hi, I need to have a query that stores the max value from one measurement into another measurement. The new max value should overwrite the old value if it’s bigger. Have not been able to find out how this can be done in a query.

Anybody who has done something similar?

There isn’t an UPDATE function, so over-writing an old max value with a new one might be a bit tricky. Would a simple query be sufficient?

SELECT max("measurement") AS "max_measurement" FROM "mydata"."autogen"."mydata_table" WHERE time > now() - 720h AND "tag"='mytag'

Would return the max value for the last 30 days. You could add this to a dashboard in Chronograf to have a real-time view of it.

I need the max query continuously so it could update the max value as soon as there is a new value bigger than the old one. But I could modify the query you propose to look for the last hour and having it run as a continuous query. That could work. Thanks for the tip :slight_smile: