Thank you! That was it. Also the table was wrong.
Final entry for the 24 hour moving average house energy level is:
- platform: sql queries: - name: '24 timer snitteffekt' query: > SELECT ROUND(AVG(avg_per_hour),2) 'value' FROM ( SELECT AVG(state) AS avg_per_hour FROM states WHERE entity_id = 'sensor.konvertert_energi' AND state != 'unknown' AND state != '' AND created > datetime('now', '-24 hours') GROUP BY DATE(created) ) avgs; column: 'value' unit_of_measurement: kW