질문 : 아래 1,2번 쿼리가 동일한 결과를 출력하는데, 3번쿼리와 동일한 결과를 출력하는 쿼리를 만들려고 하는데 잘안됩니다.
1. query -------------------------------------------------------------
select a.col1 acol, a.col2, b.col1 bcol, b.col2
from
(
select '1' col1, 10 col2 from dual union all
select '2' col1, 20 from dual union all
select '3' col1, 20 from dual union all
select '4' col1, 20 from dual union all
select '5' col1, 20 from dual
) a
full outer join
(
select '0' col1, 10 col2 from dual union all
select '1' col1, 10 from dual union all
select '2' col1, 20 from dual union all
select '4' col1, 20 from dual union all
select '5' col1, 30 from dual
) b
on ( a.col1 = b.col1 );
2. query ----------------------------------------------------------
select a.col1 , a.col2, b.col1 bcol, b.col2
from
(
select '1' col1, 10 col2 from dual union all
select '2' col1, 20 from dual union all
select '3' col1, 20 from dual union all
select '4' col1, 20 from dual union all
select '5' col1, 20 from dual
) a
,
(
select '0' col1, 10 col2 from dual union all
select '1' col1, 10 from dual union all
select '2' col1, 20 from dual union all
select '4' col1, 20 from dual union all
select '5' col1, 30 from dual
) b
where a.col1 = b.col1(+)
union
select a.col1 , a.col2, b.col1 , b.col2
from
(
select '1' col1, 10 col2 from dual union all
select '2' col1, 20 from dual union all
select '3' col1, 20 from dual union all
select '4' col1, 20 from dual union all
select '5' col1, 20 from dual
) a
,
(
select '0' col1, 10 col2 from dual union all
select '1' col1, 10 from dual union all
select '2' col1, 20 from dual union all
select '4' col1, 20 from dual union all
select '5' col1, 30 from dual
) b
where a.col1(+) = b.col1
;
3. query --------------------------------------------------------
select a.col1 acol, a.col2, b.col1 bcol, b.col2
from
(
select '1' col1, 10 col2 from dual union all
select '2' col1, 20 from dual union all
select '3' col1, 20 from dual union all
select '4' col1, 20 from dual union all
select '5' col1, 20 from dual
) a
full outer join
(
select '0' col1, 10 col2 from dual union all
select '1' col1, 10 from dual union all
select '2' col1, 20 from dual union all
select '4' col1, 20 from dual union all
select '5' col1, 30 from dual
) b
on ( a.col1 = b.col1 and b.col2='10') ;