oracle 一条语句实现将“17,20,23”拆分成‘17’,‘20’,‘23’的集合
在oracle中,使用一条语句实现将“17,20,23”拆分成‘17’,‘20’,‘23’的集合
------解决方案--------------------SELECT REGEXP_SUBSTR(TEXT,
'[0-9]+',
1,
RN) TEXT
FROM (SELECT '17,20,23' AS TEXT FROM DUAL) T1,
(SELECT LEVEL RN
FROM DUAL
CONNECT BY ROWNUM <=
(SELECT LENGTH(TEXT) -
LENGTH(REPLACE(TEXT,
',',
'')) + 1
FROM (SELECT '17,20,23' AS TEXT
FROM DUAL))) T2
------解决方案--------------------
SQL code
select regexp_substr('17,20,23', '[^,]+',1,rownum) r
from dual connect by rownum<=length('17,20,23')-length(replace('17,20,23', ',', ''))+1;