[답변]쿼리 질문입니다. 0 0 1,323

by 이주호 [2006.12.29 10:35:05]


원하시는 쿼리문인지 궁금합니다.

아래 참고하세요.

 

--- 아래 ---

select a.a
       ,a.b
       ,a.max_c
       ,a.d
       ,a.max_d
from (
       select a.a
              ,a.b
              ,a.c
              ,max(a.c) over (partition by a.a, a.b) max_c
              ,a.d
              ,min(a.d) over (partition by a.a, a.b) min_d
              ,max(a.d) over (partition by a.a, a.b) max_d
       from (
              select 1 a, 'A' b, '' c,   0 d from dual union all                          
              select 1,   'A',   'AAA',  0 from dual union all                         
              select 1,   'B',   '',     0 from dual union all                          
              select 1,   'B',   'BBB',  1 from dual union all                         
              select 1,   'C',   '',     1 from dual union all                          
              select 1,   'C',   'CCC',  1 from dual union all                          
              select 2,   'A',   '',     0 from dual union all
              select 2,   'A',   'AAA',  0 from dual union all                         
              select 2,   'B',   '',     0 from dual union all                         
              select 2,   'B',   'BBB',  1 from dual union all                         
              select 2,   'B',   'BBB',  1 from dual union all                         
              select 2,   'B',   'BBB',  0 from dual
           ) a
    ) a 
 where min_d <> max_d 
 and a.c is not null
 and a.d = 1

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입