oracle regexp正则:一行转多行-level

with tab as
 (select '0001' hr_id, 'PC-CAT Ⅱ,PC-CP' check_type
    from dual
  union
  select '0002' hr_id, 'PC-CAT Ⅱ,PC-CP' check_type
    from dual
  union
  select '0003' hr_id, 'PC-CAT Ⅱ' check_type from dual)

select * from tab

基础数据

select hr_id,
       check_type,
       regexp_substr(check_type, '[^,]+', 1, rownum) new_check_type,
       rownum
  from tab
connect by rownum <=
           LENGTH(CHECK_TYPE) - length(regexp_replace(check_type, ',')) + 1

查询结果

发布了241 篇原创文章 · 获赞 14 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/qq_29150765/article/details/85159940