title: Postgresql Completing date_trunc(ts,'hour') with missing values
body: <p>I have a table with ts values and an int for how many times an event occurs in that ts.
  The problem is that if there is no event in a ts, this ts is not recorded in the DB, like the following example:</p>
  
  <pre><code>ts                 |  n
  -------------------------
  2014-09-26 01:00:00|  10
  2014-09-26 03:00:00|  12
  2014-09-26 05:00:00|  1
  2014-09-26 06:00:00|  2
  2014-09-26 07:00:00|  4
  2014-09-26 08:00:00|  3
  </code></pre>
  
  <p>What I need to do is perform a query that can complete all the missing ts values (trun at hour) in the interval to get something like this:</p>
  
  <pre><code>ts                 |  n
  -------------------------
  2014-09-26 01:00:00|  10
  2014-09-26 02:00:00|  0
  2014-09-26 03:00:00|  12
  2014-09-26 04:00:00|  0
  2014-09-26 05:00:00|  1
  2014-09-26 06:00:00|  2
  2014-09-26 07:00:00|  4
  2014-09-26 08:00:00|  3
  </code></pre>
  
  <p>Thanks for your help!</p>