select dateadd(day,-datepart(weekday,min(a))+2,min(a)) as 周一
,dateadd(day,8-datepart(weekday,min(a)),min(a)) as 周日
,sum(b)
from T
group by datediff(week,a,getdate())
order by min(a)
--统计一年中的.
select 周数=datepart(week,a),b=sum(b) from t group by datepart(week,a)
--分月统计的.
select 月份=convert(varchar(6),a,112)
,周数=datepart(week,a)-datepart(week,a-day(a))+1,
,b=sum(b)
from t
group by convert(varchar(6),a,112),datepart(week,a)-datepart(week,a-day(a))+1