본문 바로가기
Oracle(DB관련)

sys_connect_by_path row데이터를 column데이터로

by xfree302 2009. 11. 4.
반응형
 select sys_connect_by_path(name, ',') as list
   from (select code01,
                     code02, 
                     name,
                     row_number() over(partition by code01 order by code01, code02) rn,
                     count(*) over(partition by code01) cnt
            from tb_aaa
          where code01='01' )
   where level = cnt
     start with rn = 1
connect by prior code01 = code01
           and prior rn = rn - 1
반응형

'Oracle(DB관련)' 카테고리의 다른 글

그룹별 합계, 누적합계 sum()  (0) 2009.11.04
순서정하기 rank()  (0) 2009.11.04
merge into 있으면 update, 없으면 insert  (0) 2009.11.03
페이징 처리 sql  (0) 2009.10.29
join update  (0) 2009.10.28