日期:2014-05-17 浏览次数:20477 次
select ID=row_number()over(order by getdate()),
[员工ID] ,'月份'=substring([月份],1,7),'生成总数'=sum([生成总数])
from A表 with(nololck)
where 筛选条件
group by [员工ID] ,substring([月份],1,7)
select row_number() over (order by 月份) as ID,* from
(
select 员工ID,月份 = convert(nvarchar(7),月份,25),生成总数 = sum(生产数量)
from tb
group by 员工ID,convert(nvarchar(7),月份,25)
)t