Searched by NAVER

알티베이스강좌  :  큐브리드강좌  :  오라클강좌  :  오라클팁  :  오라클사용자팁  :  Oracle Blogs  :  오라클Q&A  :  오라클자료실  :  IT컬럼/소식  :  좋은글감동  :  방명록
Oracle 질문과 답변 oracleclub.com
outer join 쿼리 질문
손종욱 : 2009-07-02 14:13  
주소복사

질문 : 아래 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') ;

조회수 237,  추천수 0
글 등 록 글 답 변 글 수 정 목록보기
※ 로그인하여 작성한 글만 삭제할 수 있습니다. 로그인
이름 쓰기
도움 주시는 곳