34,838
社区成员




create table t1(xm varchar(100),gh varchar(100))
insert into t1 values ('丁宇','001')
insert into t1 values ('丁宇','002')
insert into t1 values ('丁宇','003')
insert into t1 values ('吉乐','004')
insert into t1 values ('吉乐','006')
select xm,gh from
(select px=(select count(1) from t1 where xm=a.xm and gh<a.gh)+1,* from t1 a)
where px=2
=
SELECT XM,MAX(GH) AS GH
FROM TABLENAME
GROUP BY XM