------解决方案-------------------- select * from table a where not exists( select id from table b on a.nametype=b.nametype and a.step<b.step ) ------解决方案-------------------- select * from table a where exists (select 1 from (select nametype ,max(step)step from table where nametype ='design' group by nametype ) b where a.nametype=b.nametype and a.step=b.step) and nametype ='design' ------解决方案-------------------- code貌似不满足你的需求哦 ------解决方案-------------------- 你是不是这个意思?
select [id],[nametype], [step] from(select *,ROW_NUMBER () over (partition by nametype order by step desc) as row from [Table])t where t.row=1