日期:2014-05-18 浏览次数:20436 次
declare @t table (ID int,CODE varchar(7)) insert into @t select 5,'02Y1111' union all select 6,'02Y1111' union all select 10,'02Y1111' union all select 16,'02Y1111' union all select 17,'02Y1111' union all select 18,'02Y1111' select * from @t where ID in( select min(ID) from (select *,rid=(select count(1) from @t where ID<=a.ID) from @t a) b group by ID-rid) /* ID CODE ----------- ------- 5 02Y1111 10 02Y1111 16 02Y1111 */