各位大神,请教一个问题:
数据库表中有一下数据
id grouplist
zhangsan |23|34|45|
lisi |33|
wangwu |23||45|
这三个的权限属于不同的组,现在要把他们处理成如下个数:
id grouplist
zhangsan 23
zhangsan 34
zhangsan 45
lisi 33
wangwu 23
wangwu 45
不能用java,c#等语言处理,用oracle相关函数或者是自定义的函数
分数不多,请高数赐教,谢谢!
------解决思路----------------------
with t as(select 'zhangsan' id,'
------解决思路----------------------
23
------解决思路----------------------
34
------解决思路----------------------
45
------解决思路----------------------
' grouplist from dual union all
select 'lisi','
------解决思路----------------------
33
------解决思路----------------------
' from dual union all select 'wangwu','
------解决思路----------------------
23
------解决思路----------------------
45
------解决思路----------------------
' from dual),
u as(select id,regexp_substr(grouplist,'[[:digit:]]+.*[[:digit:]]+')grouplist from t),
v as(select id,regexp_replace(grouplist,'[^[:digit:]]+','
------解决思路----------------------
') grouplist from u)
select id,regexp_substr(grouplist,'[[:digit:]]+',1,level) grouplist from v
connect by level<=regexp_count(grouplist,'[^[:digit:]]')+1
and prior id=id
and prior sys_guid() is not null