I am working on a sql view that should get the average number of hits by hour of the day, regardless of what day/date it is for traffic monitoring (12:00:00.000 – 12:59:59.999). Any ideas?
EDIT
Now I have the total, how do I get the average? SELECT AVG(“FUNCTION BELOW”) DOES NOT WORK
SELECT COUNT(*) AS total, DATEPART(hh, LogDate) AS HourOfDay
FROM dbo.Log
GROUP BY DATEPART(hh, LogDate)
Convert to DATEPART(hh,…..
Example
SELECT DATEPART(hh,GETDATE())Since you are on SQL Server 2008, you can use the time data type, just convert to time
example
Then you can filter that also
Since I am not sure what your output is supposed to be like I am showing you both, but if all you need is to group by hour, then just do a
datepart(hh.....