I have a query (which comes from Grafana):
SELECT sum(“c”) FROM “mqtt_consumer” WHERE (“topic” = ‘PBX/Live’) AND time >= now() - 1h
So far, so good. However, I wish to ensure that the lowest value of this query is zero (ie: never negative, which is sometimes possible given the data in the table).
Therefore I want to do something like:
SELECT max(0,sum(“c”)) FROM “mqtt_consumer” WHERE (“topic” = ‘PBX/Live’) AND time >= now() - 1h
except that the max() function doesn’t work like that - it expects a single parameter which is a field key.
Any idea how I can achieve this in Influx?