Phil, It works like a charm and was relatively simple (after copying from your sample:)).
SELECT
'Hour' = DATEPART(hh, DATEADD(hh, -4, [Date AND Time])),
'Month' = DATEPART(m, DATEADD(hh, -4, [Date AND Time])),
'YEAR' = DATEPART(yy, DATEADD(hh, -4, [Date AND Time])),
'Cage 1'= Sum (Case WHEN Tag=4157 THEN 1 ELSE 0 end),
'Cage 2'= Sum (Case WHEN Tag=4158 THEN 1 ELSE 0 end),
'Cage 3'= Sum (Case WHEN Tag=4159 THEN 1 ELSE 0 end),
'Cage 4'= Sum (Case WHEN Tag=4160 THEN 1 ELSE 0 end),
'Cage 5'= Sum (Case WHEN Tag=4161 THEN 1 ELSE 0 end),
'Cage 6'= Sum (Case WHEN Tag=4162 THEN 1 ELSE 0 end),
'Cage 7'= Sum (Case WHEN Tag=4163 THEN 1 ELSE 0 end),
'Cage 8'= Sum (Case WHEN Tag=4164 THEN 1 ELSE 0 end),
'Total' = count(*)
FROM DC_Transaction
WHERE Tag > 4100
GROUP BY DATEPART(hh, DATEADD(hh, -4, [Date AND Time])), DATEPART(m, DATEADD(hh, -4, [Date AND Time])), DATEPART(yy, DATEADD(hh, -4, [Date AND Time]))
WITH rollup
One thing I was wondering though. If I wanted to:
Coalesce('Hour' = DATEPART(hh, DATEADD(hh, -4, [Date AND Time])), 'Hour Total')
SQL does not recognize the [Date And Time] when I Group By it. Meaning if I use that Coalesce function with the embedded Datepart and Dateadds, Sql thinks that I was not used the Date ANd Time column in the select list. Is there a way for SQL to recognize the column used within a coalesce when its buried in the function?