title: How to group by Date and Hour :00:00 in SQL Server 2008
body: <p>I want to create hourly report and this query is running perfectly.</p>
  
  <pre><code>SELECT 
      FORMAT(PingLogDate,'yyyy-MM-dd-HH:00:00') AS CalculatedTime, 
      COUNT(PingLogID) AS PingCount
  FROM
      tbl_PingLog
  GROUP BY 
      FORMAT(PingLogDate,'yyyy-MM-dd-HH:00:00')
  ORDER BY 
      FORMAT(PingLogDate,'yyyy-MM-dd-HH:00:00')
  </code></pre>
  
  <p>But I'm supporting SQL Server 2008 and <code>Format</code> is new in SQL Server 2012, so I tried this code </p>
  
  <pre><code>SELECT 
      CAST(PingLogDate AS date) AS CalculatedDate, 
      DATEPART(hour, PingLogDate) AS CalculatedTime, 
      COUNT(PingLogID) AS PingCount
  FROM
      tbl_PingLog
  GROUP BY 
      CAST(PingLogDate AS date), DATEPART(hour, PingLogDate)
  ORDER BY 
      CAST(PingLogDate AS date), DATEPART(hour, PingLogDate)
  </code></pre>
  
  <p>The problem is don't want to 2 column for date and hour for example </p>
  
  <p>First query's result is </p>
  
  <pre><code>CalculatedTime      | PingCount
  --------------------+-----------
  2017-11-07-12:00:00 | 359
  2017-11-07-13:00:00 | 359
  2017-11-07-14:00:00 | 350
  </code></pre>
  
  <p>Second query's result is </p>
  
  <pre><code>CalculatedDate |CalculatedTime | PingCount
  ---------------+---------------+----------
  2017-11-07     |12             | 359
  2017-11-07     |13             | 359
  2017-11-07     |14             | 350
  </code></pre>
  
  <p>I don't want second one. I want first one. How to do that with SQL Server 2008 supported tools.</p>