WITH t AS
(
SELECT 409666 a, 649027 b, 'T-54440:T-54430:T-54450:T-54460' c FROM dual
UNION ALL SELECT 409666, 649025, 'T-54260' FROM dual
UNION ALL SELECT 409666, 649028, 'T-54390:T-54380:T-54370' FROM dual
UNION ALL SELECT 412997, 665489, 'T-54320:T-54330' FROM dual
UNION ALL SELECT 412997, 665490, 'T-54280:T-54270:T-54290:T-54300' FROM dual
)
SELECT a, b
, lv
, REGEXP_SUBSTR(c, '[^:]+', 1, lv) d
FROM t
, (SELECT level lv FROM dual CONNECT BY level <= 9)
WHERE lv <= LENGTH(c) - LENGTH(REPLACE(c, ':')) + 1
ORDER BY a, b, lv
;
by 허재영
[2011.06.21 14:44:22]
WITH t AS
(
SELECT 409666 a, 649027 b, 'T-54440:T-54430:T-54450:T-54460' c FROM dual
UNION ALL SELECT 409666, 649025, 'T-54260' FROM dual
UNION ALL SELECT 409666, 649028, 'T-54390:T-54380:T-54370' FROM dual
UNION ALL SELECT 412997, 665489, 'T-54320:T-54330' FROM dual
UNION ALL SELECT 412997, 665490, 'T-54280:T-54270:T-54290:T-54300' FROM dual
)
SELECT a, b
, REGEXP_SUBSTR(c, '[^:]+', 1, level) d
FROM t
CONNECT BY CONNECT_BY_ROOT c = c
and level <= LENGTH(c) - LENGTH(REPLACE(c, ':')) + 1
댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.