declare @t table(id int,t1 char(1),t2 int)
insert into @t select 1,'a',3
insert into @t select 2,'b',12
insert into @t select 3,'a',-3
insert into @t select 4,'a',3
insert into @t select 5,'a',33
insert into @t select 6,'b',12
insert into @t select 7,'b',11
insert into @t select 8,'c', 9
insert into @t select 9,'c',-9delete a from @t a
where
(select count(*) from @t where id<=a.id and t1=a.t1 and t2=a.t2)<=
(select count(*) from @t where t1=a.t1 and t2=-a.t2)select * from @t/*
id t1 t2
---- ---- ----
2 b 12
4 a 3
5 a 33
6 b 12
7 b 11
*/
insert into @t select 1,'a',3
insert into @t select 2,'b',12
insert into @t select 3,'a',-3
insert into @t select 4,'a',3
insert into @t select 5,'a',33
insert into @t select 6,'b',12
insert into @t select 7,'b',11
insert into @t select 8,'c', 9
insert into @t select 9,'c',-9delete a from @t a
where
(select count(*) from @t where id<=a.id and t1=a.t1 and t2=a.t2)<=
(select count(*) from @t where t1=a.t1 and t2=-a.t2)select * from @t/*
id t1 t2
---- ---- ----
2 b 12
4 a 3
5 a 33
6 b 12
7 b 11
*/
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货