日期:2014-05-18  浏览次数:20595 次

以为解决了 一测试 悲剧了(再发一次)
http://http://topic.csdn.net/u/20120223/09/2a1f4502-dd66-424b-9898-a9d71a61f55e.html?64999

测试了一下没有用啊

得不到下面的表

------解决方案--------------------
SQL code
select
 员工号,sum(数量) as 数量,
 convert(varchar(10),日期,120) as 日期
from
 tb
group by
 员工号,convert(varchar(10),日期,120)

------解决方案--------------------
http://topic.csdn.net/u/20120223/09/2a1f4502-dd66-424b-9898-a9d71a61f55e.html?64999

测试没有问题呀
------解决方案--------------------
SQL code
create table tb (员工号 varchar(10), 数量 int,日期 datetime)
insert tb 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'
go

select 员工号 ,  sum(数量) 数量 , convert(varchar(10),日期,120) 日期
from tb
group by 员工号 , convert(varchar(10),日期,120)

drop table tb

/*
员工号        数量          日期         
---------- ----------- ---------- 
1001       6           2009-09-01
1002       5           2009-09-01
1001       6           2009-09-02
1002       5           2009-09-02

(所影响的行数为 4 行)
*/