看看这个方法能不能帮助你打开思路解决问题:
with t1 as (
select '用户A' as user_name,'管理员' as role_name,'123' as other from dual union all
select '用户A' as user_name,'用户主管' as role_name,'456' as other from dual union all
select '用户A' as user_name,'用户经理' as role_name,'789' as other from dual
),
t2 as (
select '权限大小第1' as role_order,'管理员' as role_name from dual union all
select '权限大小第2' as role_order,'用户主管' as role_name from dual union all
select '权限大小第3' as role_order,'用户经理' as role_name from dual
),
t3 as (
select t1.user_name,
t1.role_name,
t1.other,
t2.role_order,
row_number() over(partition by t1.user_name order by t2.role_order asc) as rn
from t1 left join t2 on (t2.role_name = t1.role_name)
)
select * from t3 where t3.rn = 1;