日期:2014-05-18 浏览次数:20558 次
select 员工号,sum(数量) as 数量,convert(varchar(10),日期,120) as 日期 from tb group by 员工号,convert(varchar(10),日期,120)
------解决方案--------------------
-- -- create table ta (empyeeno varchar(10),qty int,date datetime) -- insert ta select '1001','2','2009/9/1' union all -- select '1002','3','2009/9/1' union all -- select '1001','4','2009/9/1' union all -- select '1002','2','2009/9/1' union all -- select '1001','2','2009/9/2' union all -- select '1002','3','2009/9/2' union all -- select '1001','4','2009/9/2' union all -- select '1002','2','2009/9/2' select * from ta select empyeeno,sum(qty),date from ta group by empyeeno,date
------解决方案--------------------
select 员工号,sum(数量) as 数量,convert(varchar(10),日期,120) as 日期 from tb group by 员工号,日期