SELECT t.Account
, AVG(t.Count) AS AvgCount
, SUM(t.Count) AS SumCount
,(Datename(ww,getdate()) + ' ''' + Datename(yy,getdate())) as Period
FROM tblHFBYACC t
WHERE Datename(Year,getdate()) >= (Datename(Year,getdate()) + (DatePart(ww, getdate()) - 1) - 52)
GROUP BY t.Account
|