17,377
社区成员
发帖
与我相关
我的任务
分享
with t as (
select 1 "TID",1 "PID", 3 "STEPNO" from dual
union all select 2 ,2 , 1 from dual
union all select 3 ,2 , 2 from dual
union all select 4 ,3 , 4 from dual
union all select 5 ,3 , 5 from dual
union all select 6 ,4 , 6 from dual)
select tid,pid,stepno from(
select tid,pid,stepno,row_number() over(partition by pid order by stepno desc) rn from t
) where rn = 1
select max(tid),pid,max(stepno) from t group by pid