select time_bucket('1 day', time) as interval,
  round((last(exportenergyactive, time) - first(exportenergyactive, time))::numeric, 2) as energy
  from pv_power_measurement_t
  where time between date_trunc('month', now()) and date_trunc('month', now()) + interval '1 month'
  group by interval
  order by interval;



-- daily stats of current month




select time_bucket('1 day', time) as interval,
  round((last(exportenergyactive, time) - first(exportenergyactive, time))::numeric, 2) as energy
  from pv_power_measurement_t
  where time between date_trunc('month', now()) and date_trunc('month', now()) + interval '1 month'
  group by interval
  order by interval;