I have 2 queries:
select sum(redistributed) from measures where meter_id='3P00XX' AND $timeFilter group by time(30m)
which get sum of redistributed field for meter
'3P00XX' on 30 minutes timestep.
select sum(redistributed) from measures where operation_id='AC15' AND $timeFilter group by time(30m)
Which do the same thing, but for the whole operation ( a operation has a lot of meters ). It can be considered as total field.
So, what I want to do is a ratio,
sum_of_redistributed / total, for the meter_id for each 30 minutes.
Right now, I’m doing it in
n + 1, if n is the quantity of meters,
- 1 for the total.
And then I calculate the ratio in go, but it would be quite an improvement to get the ratio directly from a query. Is it possible ?
Is it possible to improve the query ?