WITH CTE AS (selectlocation,name,yst=ystitemcount,MTD=mtditemcount,YTD=ytditemcount,ystphr=cast(case when ystminutes > 0 then round(ystitemcount/(ystminutes/60.0),0) else 0 end as int),MTDphr=cast(case when MTDminutes > 0 then round(MTDitemcount/(MTDminutes/60.0),0) else 0 end as int),YTDphr=cast(case when YTDminutes > 0 then round(YTDitemcount/(YTDminutes/60.0),0) else 0 end as int))SELECT *, ystGRANDTOTAL= sum(yst) OVER (PARTITION BY location), MTDGRANDTOTAL= sum(MTD) OVER (PARTITION BY location), YTDGRANDTOTAL= sum(YTD) OVER (PARTITION BY location) FROM CTE;