옆으로 붙이기란 결국 조인이 되는 컬럼값을 일치시키는 것이다.
WITH T1 AS(
SELECT '1' RN, '20130711' DT, '23' CNT FROM DUAL UNION ALL
SELECT '2' RN, '20130711' DT, '25' CNT FROM DUAL UNION ALL
SELECT '3' RN, '20130711' DT, '30' CNT FROM DUAL UNION ALL
SELECT '4' RN, '20130712' DT, '43' CNT FROM DUAL UNION ALL
SELECT '5' RN, '20130712' DT, '15' CNT FROM DUAL UNION ALL
SELECT '6' RN, '20130712' DT, '13' CNT FROM DUAL UNION ALL
SELECT '7' RN, '20130712' DT, '28' CNT FROM DUAL
)
,T2 AS(
SELECT '1' RN, '20130718' DT, '10' CNT FROM DUAL UNION ALL
SELECT '2' RN, '20130719' DT, '10' CNT FROM DUAL UNION ALL
SELECT '3' RN, '20130720' DT, '20' CNT FROM DUAL UNION ALL
SELECT '4' RN, '20130721' DT, '30' CNT FROM DUAL UNION ALL
SELECT '5' RN, '20130722' DT, '40' CNT FROM DUAL UNION ALL
SELECT '6' RN, '20130723' DT, '50' CNT FROM DUAL UNION ALL
SELECT '7' RN, '20130724' DT, '60' CNT FROM DUAL
)
SELECT T1.DT
,T1.CNT
,T2.DT
,T2.CNT
FROM T1
INNER JOIN T2
ON T1.RN = T2.RN
;
댓글 없음 :
댓글 쓰기