안녕하세요.
이번에도 쿼리 좀 도와 주세요.
아무리해도 결과값처럼 짤수가 업서요..ㅠㅠ
원본
A |
A1 |
A21 |
A |
A1 |
A22 |
A |
A3 |
A23 |
A |
A3 |
A24 |
A |
A3 |
A25 |
B |
B1 |
B21 |
B |
B1 |
B22 |
B |
B2 |
B23 |
B |
B2 |
B24 |
WITH TEMP AS (
SELECT 'A' AS CD, 'A1' AS CD2, 'A21' CD3 FROM DUAL UNION ALL
SELECT 'A' AS CD, 'A1' AS CD2, 'A22' CD3 FROM DUAL UNION ALL
SELECT 'A' AS CD, 'A3' AS CD2, 'A23' CD3 FROM DUAL UNION ALL
SELECT 'A' AS CD, 'A3' AS CD2, 'A24' CD3 FROM DUAL UNION ALL
SELECT 'A' AS CD, 'A3' AS CD2, 'A25' CD3 FROM DUAL UNION ALL
SELECT 'B' AS CD, 'B1' AS CD2, 'B21' CD3 FROM DUAL UNION ALL
SELECT 'B' AS CD, 'B1' AS CD2, 'B22' CD3 FROM DUAL UNION ALL
SELECT 'B' AS CD, 'B2' AS CD2, 'B23' CD3 FROM DUAL UNION ALL
SELECT 'B' AS CD, 'B2' AS CD2, 'B24' CD3 FROM DUAL
)
SELECT *
FROM TEMP
결과
A |
|
|
|
A1 |
|
|
|
A21 |
|
|
A22 |
|
A3 |
|
|
|
A23 |
|
|
A24 |
|
|
A25 |
B |
|
|
|
B1 |
|
|
|
B21 |
|
|
B22 |
|
B2 |
|
|
|
B23 |
|
|
B24
|
위와 같은 결과가 되게 좀 도와주세요
|