하기와 같이 A,B테이블을 이용해 C테이블의 결과를 내고 싶습니다.
어떻게 하면 될지 문의 드려 봅니다.
감사합니다.
WITH A AS
(
SELECT 'A01' A, 'B01' B, 'C01' C , 'D01' D, 'E01' E, 'PMT' F , 200 G, 0 H FROM DUAL UNION ALL
SELECT 'A01' A, 'B01' B, 'C01' C , 'D01' D, 'E01' E, 'PMT' F , 1 G , 0 H FROM DUAL UNION ALL
SELECT 'A01' A, 'B01' B, 'C01' C , 'D01' D, 'E01' E, 'PMT' F , 52 G , 0 H FROM DUAL UNION ALL
SELECT 'A01' A, 'B01' B, 'C01' C , 'D01' D, 'E02' E, 'PMT' F , 21 G , 5 H FROM DUAL UNION ALL
SELECT 'A02' A, 'B02' B, 'C02' C , 'D02' D, 'E03' E, 'PMT' F , 600 G, 0 H FROM DUAL UNION ALL
SELECT 'A02' A, 'B02' B, 'C02' C , 'D02' D, 'E03' E, 'PMT' F , 71 G , 0 H FROM DUAL UNION ALL
SELECT 'A02' A, 'B02' B, 'C02' C , 'D02' D, 'E03' E, 'PMT' F , 5 G , 0 H FROM DUAL UNION ALL
SELECT 'A02' A, 'B02' B, 'C02' C , 'D02' D, 'E04' E, 'PMT' F , 36 G , 3 H FROM DUAL
)
SELECT *
FROM A;
WITH B AS
(
SELECT 'A01' A, 'B01' B, 'C01' C, 'D01' D, 'E02' E, 'PMT' F FROM DUAL UNION ALL
SELECT 'A02' A, 'B02' B, 'C02' C, 'D02' D, 'E04' E, 'KBS' F FROM DUAL
)
SELECT *
FROM B;
WITH C AS
(
SELECT 'A01' A, 'B01' B ,'C01' C , 'D01' D , 'E02' E , 'AGG' F, 21 G, 5 H FROM DUAL UNION ALL
SELECT 'A02' A, 'B02' B ,'C02' C , 'D02' D , 'E04' E , 'AGG' F, 0 G, 0 H FROM DUAL
)
SELECT *
FROM C;
|