title: Query data for hour by hour report
body: <p>I've been tasked with a report that will show a bar chart where the X-axis is the hours of the shift, so 1-8 along the bottom. The bars are the number of transactions accomplished per hour. So the bar chart would easily let you see that in the first hour we've processed 30 orders, hour 2 we've processed 25, and so on, to the end of the shift.</p>
  
  <p>I'm having trouble figuring out how to actually create this report though. Is my only option to do something like this (understand this is just pseudo-code, don't bother commenting on syntax issues):</p>
  
  <pre><code>create table #temp
  (
    Hour int,
    Units int
  )
  
  insert into #temp
  SELECT 1 as Hour, sum(Units) Units
  FROM orders
  WHERE DateCreated &gt;= '6/14/2013 08:00:00' AND DateCreated &lt; '6/14/2013 09:00:00'
  
  insert into #temp
  SELECT 2 as Hour, sum(Units) Units
  FROM orders
  WHERE DateCreated &gt;= '6/14/2013 09:00:00' AND DateCreated &lt; '6/14/2013 10:00:00'
  
  insert into #temp
  SELECT 3 as Hour, sum(Units) Units
  FROM orders
  WHERE DateCreated &gt;= '6/14/2013 11:00:00' AND DateCreated &lt; '6/14/2013 12:00:00'
  
  .. and so on ..
  
  select * from #temp
  </code></pre>
  
  <p>Also, this is in a stored procedure that the report calls.</p>
  
  <p>Is there a better way to do this? Should I be just sending the entire day's data to the report and somehow handling it there? Any insights would be appreciated.</p>