oracle 一行转多行

Posted 不想想太多 - Faded

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 一行转多行相关的知识,希望对你有一定的参考价值。

比如sql:

select zyxdm from table where bindid=2265254

查询结果为:1|4|8|9|10

将这个查询结果转成多行,结果如下:
ID
1
4
8
9
10

  转换的sql :

with CTE1 as (select zyxdm from table where bindid=2265254)
SELECT REGEXP_SUBSTR((select * from CTE1), ‘[^|]+‘, 1, ROWNUM) id
FROM DUAL CONNECT BY ROWNUM <= LENGTH((select * from CTE1))
- LENGTH(REPLACE((select * from CTE1), ‘|‘, ‘‘)) + 1

  





以上是关于oracle 一行转多行的主要内容,如果未能解决你的问题,请参考以下文章