3 回答

TA貢獻1783條經(jīng)驗 獲得超4個贊
WITH temp as
(
select '111' as userid,'5' as status,'7' as ord from dual
union all
select '111' as userid,'0' as status,'9' as ord from dual
union all
select '111' as userid,'1' as status,'8' as ord from dual
union all
select '222' as userid,'3' as status,'3' as ord from dual
union all
select '222' as userid,'1' as status,'2' as ord from dual
union all
select '222' as userid,'2' as status,'4' as ord from dual
union all
select '333' as userid,'3' as status,'10' as ord from dual
)
select userid,status,ord from (
select userid,status,ord,row_number() over(partition by userid order by ord desc) rn
from temp
)
where rn=1
;
- 3 回答
- 0 關注
- 1796 瀏覽
添加回答
舉報