select * from tb t where not exists ( select 1 from tb where t.id=id and t.C>C )
select * from 表名 a where not exists(select 1 from 表名 where a.id=id and C<a.C)
--or select a.* from 表名 a,(select id,c=min(c) from 表名 group by id)b where a.id=b.id and a.c=b.c
create table #t(id int,b int,c int)insert into #t select 1,1,2 union all select 1,2,1 union all select 2,2,1 union all select 2,1,2 union all select 3,1,2 union all select 3,1,1select * from #t as out where c = (select min(c) from #t as inn where inn.id = out.id) drop table #t
from
tb t
where not exists
(
select 1 from tb where t.id=id and t.C>C
)
select * from 表名 a
where not exists(select 1 from 表名 where a.id=id and C<a.C)
--or
select a.* from 表名 a,(select id,c=min(c) from 表名 group by id)b
where a.id=b.id and a.c=b.c
create table #t(id int,b int,c int)insert into #t
select 1,1,2 union all
select 1,2,1 union all
select 2,2,1 union all
select 2,1,2 union all
select 3,1,2 union all
select 3,1,1select *
from #t as out
where c = (select min(c) from #t as inn where inn.id = out.id)
drop table #t