I’m using influx 1.7 and have a question about aggregating results of a subquery.
The result of the subquery is this:
name: measurements
tags: sensorId=sensor1
time value
---- -----
2020-06-13T02:00:00+02:00 10496.30479359464
2020-06-13T03:00:00+02:00 10818.674817088533
name: measurements
tags: sensorId=sensor2
time value
---- -----
2020-06-13T02:00:00+02:00 20452.49079731096
2020-06-13T03:00:00+02:00 21042.71584202803
I wish to sum the data over tags, but keep the time grouping.
Required result:
name: measurements
time value
---- -----
2020-06-13T02:00:00+02:00 30948.7955909
2020-06-13T03:00:00+02:00 31861.3906591
Somehow if I wrap the subquery, it returns 480 results.
Wrapping query:
select sum(value) as value
from(
<<subquery>>
)
where
time >= '2020-06-13T00:00:00Z' and
time < '2020-06-13T02:00:00Z'
group by
time(1h)
tz('Europe/Amsterdam')
The first few lines of the actual result are:
name: measurements
time value
---- -----
2020-06-13T02:00:00+02:00 287.94145560581165
2020-06-13T03:00:00+02:00 0
2020-06-13T02:00:00+02:00 562.0502567542244
2020-06-13T03:00:00+02:00 0
2020-06-13T02:00:00+02:00 335.88116890711143
2020-06-13T03:00:00+02:00 0
2020-06-13T02:00:00+02:00 651.9935981011204
2020-06-13T03:00:00+02:00 0
2020-06-13T02:00:00+02:00 340.9463575063458
2020-06-13T03:00:00+02:00 0
... (470 more lines)
Can someone help me to get to the required result? And maybe explain what is happening that returns the 480 results?
I posted a simplified version of the query, as this is the part that is still failing. If more details are required, I am happy to share.