I have sensors emitting data every ~20 seconds. However sometimes these are in trouble and doesn't emit data for minutes or hours.

I would like to fetch those disconnection and know how long these last.

So I tried with the function `time_bucket` to count number of data by bucket of 5 minutes (for example), but this function only affect the data itself. So it isn't possible to fetch bucket HAVING COUNT(\*) = 0.

I tried this :

```
SELECT time_bucket('5 minutes', datetime) AS bucket, COUNT(*) AS nb_datas
FROM measures
WHERE id_sensor = 123456
GROUP BY bucket
HAVING COUNT(*) = 0
ORDER BY bucket DESC;

```

But logically it return nothing.

A little help would be apprecied :)