title: SQL query breakdown the sales by each hour
body: <p>I have a query as below which will return each Remote server sales for today
  Result as per below</p>
  
  <pre><code>datebooking NameOfDay   ORC CWP TC  TotalBooking    EmailSent   EmailNotSent
  20150524    Sunday      447 144 272  1441           1441           0
  </code></pre>
  
  <p>The datebooking actually i have it trim down to 8 numeric</p>
  
  <p>My question is could I return each remote sales server breakdown by per hour? Imagine one day will be 24 lines of details instead of one line per day
  That mean under booking date will we in this format 20150524 12am to 1am sales, 2am  to 3am so on and so forth? How should I accomplish this query based on my current query?   </p>
  
  <pre><code>SELECT 
      Convert(char(8), OrderH_dtmInitiated, 112)as datebooking,
        Datename (weekday, OrderH_dtmInitiated) As NameOfDay,
         --count(distinct OrderH_strCinemaId)as Cinemasite,   
         SUM(case when OrderH_strCinemaId like '1101' then 1 else 0 end)as ORC,
         SUM(case when OrderH_strCinemaId like '1102' then 1 else 0 end)as CWP,
         SUM(case when OrderH_strCinemaId like '1104' then 1 else 0 end)as TC,
         count(distinct OrderH_intID)as TotalBooking,  
         SUM(case when OrderH_strEmailConfirmationSent like 'Y' then 1 else 0 end) as EmailSent,
         SUM(case when OrderH_strEmailConfirmationSent is NULL then 1 else 0 end) as EmailNotSent   
  
      FROM [VISTAIT].[dbo].[tblOrderHistory]
      WHERE OrderH_dtmInitiated &gt;= (SELECT     DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE() )))
      GROUP BY Convert(char(8), OrderH_dtmInitiated, 112), Datename (weekday, OrderH_dtmInitiated )
      ORDER by Convert(char(8), OrderH_dtmInitiated, 112) 
  </code></pre>