Sum of values where is the mistake

Dear all,

i have a database (InflucDB) who contain a value of the instant watt consumption of my house. Every 10 sec (if there isn’t error) the device read the real consumption and save it in the database.
In influxdb for know the total consumption in a certain period I use this query:

select sum(*) from (select sum(“value”) / count(“value”) from “W” where time >= ‘2018-04-29’ AND time <= ‘2018-04-30’) group by time(1h);

Now I would do this in Grafana using a $timeFilter so I can choose the period. But something goes wrong. Why the sum doesn’t work?? The value is not correct.
Here is the result…

“group by time” part in outer query is your problem.

Sorry but I don’t understand where is the problem?