22,301
社区成员




create table #(id int,num int,date varchar(10))
insert into #
select 1 ,35, '2010-9-10'union all
select 1 ,36, '2010-9-11'union all
select 1 ,34 ,'2010-9-12'union all
select 2 ,35 ,'2010-9-10'union all
select 2 ,34 ,'2010-9-11'union all
select 3 ,34 ,'2010-9-12'union all
select 3 ,35 ,'2010-9-11'union all
select 3 ,36 ,'2010-9-10'
select id, num ,date from # a where not exists (select 1 from # b where a.id=b.id And a.date<b.date )
1 34 2010-9-12
2 34 2010-9-11
3 34 2010-9-12
select id, num ,date from TB a where not exists (select 1 from TB where a.id=id And a.date<date )