我的查询是:
select A.*
from (select r.role_id,
r.role_name,
r.active,
decode( r.entity_type_id, 1000, m.name, 3000, cour.name, 4000, 'Ensenda' ) companyName,
LISTAGG(p.permission_id, ' | ') WITHIN GROUP (ORDER BY r.role_id) permission_id,
LISTAGG(p.permission_name, ' | ') WITHIN GROUP (ORDER BY r.role_id) permission_name,
row_number() over (order by r.created_ts desc) as RN,
count(*) over () as TOTAL_ROWS,
r.created_ts roleCreated
from t_role r
left join t_role_permission rp ON r.role_id = rp.role_id
left join t_permission p ON rp.permission_id = p.permission_id
left join merchant m on r.entity_id = m.merchantkey
left join courier cour on r.entity_id = cour.courierkey
where 1=1
--and p.permission_id =301446
group by r.role_id, r.role_name, r.active, r.created_ts,
decode( r.entity_type_id, 1000, m.name, 3000, cour.name, 4000, 'Ensenda' )
) A
where RN between 1 and 100 order by roleCreated desc
我的结果是:
现在我想以permission_id
这样一种方式过滤列表,我想要在permission_id 列中与该permission_id 匹配的所有记录的列表。
例如:假设我为permission_id= 301446
. 我想要以下结果
PS:p.permission_id=301446
在 where 子句中添加 and 不会产生预期的结果。