34,590
社区成员
发帖
与我相关
我的任务
分享
create table tb(a char(2),b char(2),c char(2))
insert into tb
select '1','9','a' union all
select '1','8','b' union all
select '1','6','c' union all
select '2','9','d' union all
select '2','7','e' union all
select '2','1','f'
select * from tb where b in (select max(b) from tb group by a)
a b c
---- ---- ----
1 9 a
2 9 d
(2 行受影响)
select * from [Table] a where not exists(select 1 from [Table] where a=a.a and b>a.b)