SQL Server Group by Count of DateTime Per Hour? - Stack Overflow
How about this? Assuming SQL Server 2008: SELECT CAST(StartDate as date) AS ForDate, DATEPART(hour,StartDate) AS OnHour, COUNT(*) AS Totals FROM #Events GROUP BY CAST(StartDate as date), DATEPART(hour,StartDate) For pre-2008: ......