title: Timescaledb time_bucket fetch periods with no row
body: <p>I have sensors emitting data every ~20 seconds. However sometimes these are in trouble and doesn't emit data for minutes or hours.</p>
  
  <p>I would like to fetch those disconnection and know how long these last.</p>
  
  <p>So I tried with the function <code>time_bucket</code> 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.</p>
  
  <p>I tried this :</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>But logically it return nothing.</p>
  
  <p>A little help would be apprecied :) </p>