I have created a hypertable water_meter to store the sensor data
It contains following data ordered by timestamp in ascending order
select * from water_meter order by time_stamp;
As can be seen I have data starting from 01 May 2020
if I use time_bucket() function to get aggregates per 1 day as:
SELECT
time_bucket('1 days', time_stamp) as bucket,
thing_key,
avg(pulsel) as avg_pulse_l,
avg(pulseh) as avg_pulse_h
FROM
water_meter
GROUP BY thing_key, bucket;
It works fine and I get below data:
Now if I use it to get 15 days aggregates, I get unexpected results where the starting time bucket is shown for 17 April 2020
, for which there was no data in the table
SELECT
time_bucket('15 days', time_stamp) as bucket,
thing_key,
avg(pulsel) as avg_pulse_l,
avg(pulseh) as avg_pulse_h
FROM
water_meter
GROUP BY thing_key, bucket;