试试
sel ect b.[年份],b.[月份],b.[周次],b.[营业员姓名],MAX(b.[本周销售额])
from
(SELEC T
cast(datename(year,a.[业务日期])as int) AS [年份],
cast(datename(month,a.[业务日期])as int) AS [月份],
cast(datename(week,a.[业务日期])as int) AS [周次],
a.[营业员姓名],
sum(a.[销售额]) as 本周销售额 ,
a.[单号]
FROM
dbo.worksheet as a
GROUP BY
cast(datename(year,a.[业务日期])as int) ,
cast(datename(month,a.[业务日期])as int) ,
cast(datename(week,a.[业务日期])as int) ,
a.[营业员姓名],
a.[单号]) as b
group by b.[年份],b.[月份],b.[周次],b.[营业员姓名]