将一串数字转换成多列数据

 
with t as 
(select '123456789' numbr from dual
union all
select '234567'numbr from dual
union all
select '1234'numbr from dual),
t1 as 
(select ltrim(REGEXP_REPLACE(numbr,'\d{0}',','),',') id from t
)
 SELECT id,REGEXP_SUBSTR(id, '[^,]+', 1, 1) string1,
       REGEXP_SUBSTR(id, '[^,]+', 1, 2) string2,
       REGEXP_SUBSTR(id, '[^,]+', 1, 3) string3,
       REGEXP_SUBSTR(id, '[^,]+', 1, 4) string4,
       REGEXP_SUBSTR(id, '[^,]+', 1, 5) string5,
       REGEXP_SUBSTR(id, '[^,]+', 1, 6) string6,
       REGEXP_SUBSTR(id, '[^,]+', 1, 7) string7,
       REGEXP_SUBSTR(id, '[^,]+', 1, 8) string8,
       REGEXP_SUBSTR(id, '[^,]+', 1, 9) string9
FROM   t1

结果如下:


将一串数字转换成多列数据_第1张图片

你可能感兴趣的:(Development)