WITH bucketed as ( SELECT sensor_id, time_bucket('1 day', time) as bucket, counter_agg(time, value) as counter_agg FROM public.counters -- Over DST in Spring, dosen't work WHERE sensor_id in(36,38) AND time >= '2014-03-28 01:00:00+01' AND time < '2014-04-02 02:00:00+02' -- After DST -> works --WHERE sensor_id in(36,38) AND time >= '2014-04-03 01:00:00+01' AND time < '2014-12-30 02:00:00+02' GROUP BY 1, 2 ORDER BY 1, 2 ) SELECT sensor_id, bucket, interpolated_delta( counter_agg, bucket, '1 day', LAG(counter_agg) OVER (PARTITION BY sensor_id ORDER by bucket ASC), LEAD(counter_agg) OVER (PARTITION BY sensor_id ORDER by bucket ASC) )::DECIMAL(13, 3) FROM bucketed WINDOW ordered_meter AS (PARTITION BY sensor_id ORDER BY bucket) ORDER BY sensor_id, bucket;