select gmsfzh, xm, hjszd, rylxfrom ( select a.gmsfzh, -- 身份证号码 a.xm, -- 姓名 a.hjszd, -- 户籍所在地 a.rylx, -- 人员类型 row_number() over( partition by a.gmsfzh order by a.gxsj desc ) as rk from tablename a ) where rk =1