Wonderful, everything worked.

I first deleted all old entries from `sensor.gaszaehler_kwh`

manually.

Then copied the old values from `sensor.gaszaehler`

to `sensor.gaszaehler_kwh`

`insert into statistics (created, start, state, sum, metadata_id) select created, start, state, sum, (select id from statistics_meta where statistic_id = 'sensor.gaszaehler_kwh') from statistics where metadata_id = (select id from statistics_meta where statistic_id = 'sensor.gaszaehler') order by created asc`

`asc`

was the right sorting.

and then recalculated the new values from `sensor.gaszaehler_kwh`

.

`update statistics set state = state * 10.209547, sum = sum * 10.209547 where metadata_id = (select id from statistics_meta where statistic_id = 'sensor.gaszaehler_kwh')`

**All data from the past is displayed correct, wonderful! Thank you very much.**

For everyone with the same problem, to calculate from m³ to kWh I used the formula my supplier is also using.

`m³ * condition number * calorific value`

so in my case

`m³ * 0,9043 * 11,290`