Open swa72 opened 1 year ago
SELECT * FROM
statisticsWHERE
metadata_id="117" AND
start_ts> XXX
select t.*, t.sum - t.sum_previous as difference from (select s.*, lag(s.sum) over (partition by s.metadata_id order by s.start_ts) as sum_previous from statistics s) t where t.metadata_id = 117 and t.sum < t.sum_previous order by t.start_ts desc;
Then run
UPDATE statistics
SET sum = sum + 5816.840000004125
WHERE metadata_id
="117"
AND
id
>=2992418
and afterwards fix the absolute last value in ID117 manually
see https://github.com/home-assistant/frontend/issues/17010