Get kWh from continous W values over given time period

Using MQTT and Node-Red, I record the current consumption in watts every second in an InfluxDB table.

I would like to determine the consumption in kWh over a given period of time.

9:00:01 100 watts
9:00:02 100 watts
9:00:03 100 watts

So if a consumption of 100 watts is measured every second, the period is the last three hours, then the consumption is 300Wh or 0.3kWh.

I think the select statement should look something like this:
select sum( “watt” ) / 3h from “table” where time >= now-3h and time <= now group by time( 1s )

I use Grafana as a frontend. I asked the same question there, but unfortunately no one was able to answer.

I want to plot history and total consumption from history in Grafana.