也就是 当nametype 为‘design’ 且step为最大时查询出来 ,相同的nametype 根据step取最新的数据 ------解决方案-------------------- 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