3,496
社区成员




select regexp_substr('11;22;33;44;55;','[^;]+',1,rownum)
from dual connect by rownum<=5
with tt as
(
select 1 objID, 'aa,bb' str from dual
union all
select 2, 'aa,cc' from dual
union all
select 3, 'bb,cc' from dual
union all
select 4, 'bb,dd' from dual
union all
select 5, 'cc,ee' from dual
union all
select 6, 'cccdd,ff'from dual
)
select str ,count(*) from (
select objid ,str from (
select objid ,regexp_substr(str,'\w+',1,1) str from tt
union all
select objid ,regexp_substr(str,'\w+',1,2) str from tt where regexp_substr(str,'\w+',1,2) is not null
union all
select objid ,regexp_substr(str,'\w+',1,3) str from tt where regexp_substr(str,'\w+',1,3) is not null)
) group by str
with temp as
(
select 1,'aa' a,'bb' b from dual
union all
select 2,'aa','cc' from dual
union all
select 3,'bb','cc' from dual
union all
select 4,'bb','dd' from dual
union all
select 5,'cc','ee' from dual
union all
select 6,'cc','ff' from dual
)
select a,count(a)
from
(
select a from temp
union all
select b from temp
)
group by a
--result:
1 2 aa
2 3 bb
3 4 cc
4 1 dd
5 1 ee
6 1 ff