Hi all, using InfluxQL v1 I am trying to sum field values from multiple fields, over a given time range. I am trying this query:
SELECT sum(/^cumulus|rad|sdb$/) as Infra
FROM iota_06.rt_energy.energy WHERE time >= now() - 24h and time <= now() fill(0)
… but this yields 3 columns (Infra_cumulus, Infra_rad, Infra_sdb) - I would simply like them those 3 columns summed up… any suggestion?
I sent through the manual & the examples I could find but I can’t figure out how to write the query.
It’s good to see you back!
hmm its been so long since I’ve used InfluxQL lol. Most of our users use 2.x and Flux now.
are Infra_cumulus, Infra_rad, Infra_sdb all fields?
I think it would look like:
SELECT sum_1 + sum_2
(SELECT SUM("field1") AS sum_1, SUM("field2") AS sum_2 FROM iota_06.rt_energy.energy WHERE time >= now() - 24h and time <= now() fill(0))
But I’m not 100% sure…(yikes it’s been a while) Can you please give it a try and let me know?
Alternatively if you’re using 1.x, then you can try the following flux query (just fyi).
from(bucket: "energy ")
|> filter(fn: (r) => r["_measurement"] == " iota_06.rt_energy")
|> filter(fn: (r) => r["_field"] == "field1" or r["_field"] == "field2")