I am not quite sure what you are doing, but the obvious problem with your query is that [DateTime] is both a calculated column and a table column.(ie I suspect that you want to group by the calculated column which will not be in scope by the time the GROUP BY is applied.)Maybe you want something like:SELECT SUM(In_Maxbps) AS Combined_In_Maxbps ,GroupTimeFROM( SELECT In_Maxbps ,DATEADD(mi, DATEDIFF(mi, 0, [DateTime]) / 5 * 5, 0) AS GroupTime FROM InterfaceTraffic_Detail WHERE InterfaceID IN (<id1>, <id2>) AND [DateTime] BETWEEN @StartDate AND @EndDate) DGROUP BY GroupTimeORDER BY Combined_In_Maxbps
ps. The logical order of evaluation of the main SQL clauses is something like:FROM (including JOINs)WHEREGROUP BYHAVINGSELECTDISTINCTORDER BYTOP