[답변]group by를 사용해서 결과값을 멀티로 받을수 있나요? 0 1 2,120

by 백해현 [2006.10.16 14:55:01]


  with
       t_table as
     (
       select 1 as seq, '2006' as year, 1 as quarter, 1 as gubun, '김' as name from dual union all
       select 2 as seq, '2006' as year, 1 as quarter, 2 as gubun, '이' as name from dual union all
       select 3 as seq, '2006' as year, 1 as quarter, 3 as gubun, '박' as name from dual union all
       select 4 as seq, '2006' as year, 1 as quarter, 3 as gubun, '성' as name from dual union all
       select 5 as seq, '2006' as year, 1 as quarter, 3 as gubun, '강' as name from dual union all
       select 6 as seq, '2006' as year, 1 as quarter, 3 as gubun, '최' as name from dual
     )
select gubun
     , substr (max (sys_connect_by_path (name, ',')), 2)
  from
     (
       select gubun
            , name
            , row_number() over (partition by gubun order by seq) as rnum
         from t_table
     )
      start with rnum    = 1
connect by prior rnum    = rnum - 1
       and prior gubun   = gubun
     group by gubun
 
by 손님 [2006.10.16 00:00:00]
덕분에 잘 모르던 여러가지를 알아볼수 있었습니다.
너무 감사드립니다. (_ _)
댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입