日期:2014-05-17 浏览次数:20400 次
create table test1
(id int,name nvarchar(100),[desc] nvarchar(100),coin float,createts datetime)
insert into test1 values
(101,'tom','C',100,'2013-02-23 22:17:28.000'),
(102,'tom','A C',10,'2013-02-23 22:17:28.000'),
(103,'PETER','C',50,'2013-02-23 21:51:55.000'),
(104,'MARY','C',80,'2013-02-23 21:06:48.000'),
(105,'MARY','A C',20,'2013-02-23 21:06:48.000')
select id=min(id),name,coin=sum(coin),createts from test1 group by name,createts order by min(id)