求SQL语句,急!!
表A:
id peo date consumemoney fundmoney surplusmoney count
1984918 00361016 2007-07-20 16:22:40 3.60 .0000 3.2500 171
2352268 00361016 2007-07-24 21:08:20 0.00 150.00 153.25 172
2352400 00361016 2007-07-24 21:09:59 0.00 150.00 153.25 172
2352402 00361016 2007-07-24 21:10:00 0.00 150.00 153.25 172
2483697 00361016 2007-07-25 11:16:53 2.00 .0000 151.25 173
2308706 00009908 2007-07-24 11:55:50 4.2000 .0000 244.4500 2833
2419063 00009908 2007-07-25 09:39:00 0.00 150.0000 394.4500 2834
2419085 00009908 2007-07-25 09:39:31 0.00 150.0000 544.4500 2835
2468308 00009908 2007-07-25 12:05:48 4.2000 .0000 540.2500 2836
2450131 00009908 2007-07-25 15:04:37 0.00 150.0000 690.2500 2837
2617442 00002726 2007-07-26 11:47:18 4.2000 .0000 2.0000 2149
2597997 00002726 2007-07-26 11:57:01 .0000 50.0000 52.0000 2150
2597998 00002726 2007-07-26 11:57:02 .0000 50.0000 52.0000 2150
如何通过SQL语句得到如下结果:
id peo date consumemoney fundmoney surplusmoney count
1984918 00361016 2007-07-20 16:22:40 3.60 .0000 3.2500 171
2352402 00361016 2007-07-24 21:10:00 0.00 150.00 153.25 172
2483697 00361016 2007-07-25 11:16:53 2.00 .0000 151.25 173
2308706 00009908 2007-07-24 11:55:50 4.2000 .0000 244.4500 2833
2419063 00009908 2007-07-25 09:39:00 0.00 150.0000 394.4500 2834
2419085 00009908 2007-07-25 09:39:31 0.00 150.0000 544.4500 2835
2468308 00009908 2007-07-25 12:05:48 4.2000 .0000 540.2500 2836
2450131 00009908 2007-07-25 15:04:37 0.00 150.0000 690.2500 2837
2617442 00002726 2007-07-26 11:47:18 4.2000 .0000 2.0000 2149
2597997 00002726 2007-07-26 11:57:01 .0000 50.0000 52.0000 2150
急,求各位帮帮忙!谢谢!
------解决方案--------------------select * from a x
where not exists (
select 1 from a
where peo=x.peo
and consumemoney=x.consumemoney
and fundmoney=x.fundmoney
and surplusmoney=x.surplusmoney
and [count]=x.[count]
and id> x.id
)
------解决方案--------------------你看这样可以吗?
--创建表
DECLARE @t table
(peo int,date datetime, consumemoney money,
fundmoney money, surplusmoney money ,[count] int, [type] varchar(20))
--插入数据
insert @