title: Insert Dates in the return from a query where there is none
body: <p>We are building a query to count the number of events per hour, per day. Most days there are hours that do not have any activity and therefore where the query is run the count of activities per hour show up but there are gaps and the query excludes these. We still want to show the hours that do not have activity and display a zero so that zero value can then be charted. The query we using looks like this …</p>
  
  <pre><code>select datepart(Year, dev_time) as Year,
      datepart(Month, dev_time) as Month,
      datepart(Day, dev_time) as Day,
      datepart(Hour, dev_time) as Hour,
      count(tdm_msg) as Total_ACTIVITES
  from TCKT_ACT
  where tdm_msg = ‘4162′ and dev_time &gt;= DATEADD(day, - 1, GETDATE())
  group by datepart(Year, dev_time) ,
      datepart(Month, dev_time) ,
      datepart(Day, dev_time),
      datepart(Hour, dev_time)
  order by datepart(Year, dev_time) asc,
      datepart(Month, dev_time) asc,
      datepart(Day, dev_time) asc,
      datepart(Hour, dev_time) asc
  </code></pre>