3 回答
TA贡献1783条经验 获得超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 关注
- 1695 浏览
添加回答
举报