Я хочу подвести итог, где пункт. Я не знаю, как показать off_duration в следующем столбце.
SELECT CAST([RecordDateTime] AS DATE) AS DATE
,SUM(CAST([units] AS FLOAT)) AS Units
,sum(cast(duration AS INT) / 60) on_duration
FROM [Energies]
WHERE duration_mode = 'ON'
GROUP BY CAST([RecordDateTime] AS DATE)
ORDER BY CAST([RecordDateTime] AS DATE) DESC
op
Datet units on_duration
-------------------------------
2020-01-17 3.53 758
2020-01-16 7.66 973
2020-01-15 15.12 1806
2020-01-13 10.4 500
ex op
date units on_duration off_duration
-----------------------------------------------
2020-01-17 3.53 758 28
2020-01-16 7.66 973 9
2020-01-15 15.12 1806 96
2020-01-13 10.4 500 95
пример данных
duration_mode duration RecordDateTime units
-------------------------------------------------------------
ON 187 2020-01-07 20:18:33.9744232 0.19
ON 187 2020-01-07 20:19:03.1554359 0.19
OFF 10 2020-01-07 20:22:13.5283932 0.00
ON 187 2020-01-07 20:24:39.0510166 0.19