Hi, I'm trying to group results from a table by hour range, and then by day. So for example, any records between the hours of 1pm and 2pm on Mondays should be grouped together. Records between 1pm and 2pm on Wednesdays would be counted as a different group. I've read through some other similar posts here and tried to use the same logic but my results are not being grouped.Results I'm getting:SvcCampus| Count| TimeIn|D| 1| 2012-09-18 08:45:00.000|D| 1| 2012-09-04 09:00:00.000|D| 1| 2012-09-04 09:15:00.000|D| 1| 2012-09-04 09:50:00.000|D| 1| 2012-09-25 09:05:00.000|D| 1| 2012-09-19 09:40:00.000|D| 1| 2012-09-06 09:55:00.000|Results I want:SvcCampus| Count| TimeIn|D| 1| 2012-09-18 08:45:00.000|D| 4| 2012-09-04 09:30:00.000|D| 1| 2012-09-19 09:40:00.000|D| 1| 2012-09-06 09:55:00.000|The red line illustrates how I would like to group the four times that occurred on a Tuesday between the hours of 9:00 and 10:00. I made up the time of 9:30. I don't really care what time the four records become as long as it's something between 9:00 and 10:00.SELECT SvcCampus, COUNT(*) AS [Count], TimeIn FROM ( SELECT SvcCampus, DATEADD(MINUTE, FLOOR(DATEDIFF(MINUTE, '20000101', TimeIn)/5.0)*5, '20000101') AS TimeIn FROM Visits ) AS colsGROUP BY SvcCampus, TimeInORDER BY DATEPART(hh, TimeIn), DATEPART(dw, TimeIn) + @@DATEFIRST ASC
thanks,CJ