I'm trying to sum
the max
values of a column named value1
grouped by sensor id value so I want the last greater value from each sensor id.
Using this code I get a column with rows with the max results for each sensor. But I dont know how to sum this values.
select max(value1) from `digiwork_esp-data`.SensorData group by sensor
I need to sum this individual values of the result into a total. I tried this, but it is returning a big number (not correct):
select sum(value1)
from `digiwork_esp-data`.SensorData
where value1 = any (SELECT max(value1) FROM `digiwork_esp-data`.SensorData group by sensor)