with t1(col1, col2) as ( select 'A', 0 from dual union all select 'B', 1 from dual ) , t2(col1, col2) as ( select 'AA', 0 from dual union all select 'BB', 1 from dual union all select 'CC', 2 from dual union all select 'DD', 3 from dual ) select max(col1) col, max(col2) col2, max(col3) col3, max(col4) col4 from ( select col1, col2, null col3, null col4 , row_number() over (order by col1) rn --정렬기준, 기준 없으면 rownum from t1 union all select null col1, null col2, col1 col3, col2 col4 , row_number() over (order by col1) rn --정렬기준, 기준 없으면 rownum from t2 ) group by rn order by rn
with t1(col1, col2) as ( select 'A', 0 from dual union all select 'B', 1 from dual ) , t2(col1, col2) as ( select 'AA', 0 from dual union all select 'BB', 1 from dual union all select 'CC', 2 from dual union all select 'DD', 3 from dual ) SELECT T1.col1 , T1.col2 , T2.col1 AS col3 , T2.col2 col4 FROM T2 , T1 WHERE T2.col2 = T1.col2(+)
/* 항상 답에만 맞추는 ... 아찌 */ with t1(col1, col2) as ( select 'A', 0 from dual union all select 'B', 1 from dual ) , t2(col1, col2) as ( select 'AA', 0 from dual union all select 'BB', 1 from dual union all select 'CC', 2 from dual union all select 'DD', 3 from dual ) SELECT T1.col1 , T1.col2 , T2.col1 AS col3 , T2.col2 col4 FROM T1 FULL OUTER JOIN T2 ON T1.col2 = T2.col2