관리 메뉴

IT.FARMER

oracle 10g 이상 WM_CONCAT (여러 row 를 한컬럼에) 본문

DataBase/oracle

oracle 10g 이상 WM_CONCAT (여러 row 를 한컬럼에)

아이티.파머 2011. 8. 30. 10:52
반응형

 

 

 

1. oracle 10g 이상  WM_CONCAT2. 9i때는 xmlelement 등장



oracle 10g 이상

REPLACE (WM_CONCAT (FIELD_NAME), ',', '$') AS COUNT_MAP,



oracle 9i 이상

REPLACE (substr( xmlagg(xmlelement(nm,',', FIELD_NAME)).extract('//text()'),2), ',', '$') AS COUNT_MAP



oracle 9i 이하 아래 참조.(partition by ,connect by prior 조합.)
http://mycup.tistory.com/entry/SQLORACLE-%EC%97%AC%EB%9F%AC-%ED%96%89%EC%9D%98-%ED%8A%B9%EC%A0%95-%EC%BB%AC%EB%9F%BC%EA%B0%92-%ED%95%98%EB%82%98%EC%9D%98-%EC%BB%AC%EB%9F%BC%EC%9C%BC%EB%A1%9C-%ED%95%A9%EC%B9%98%EA%B8%B0 


참고 자료 : 

필드가 2개 인경우 

SELECT substr(xmlagg(xmlelement(nm,'/',keyword||','||cnt)).extract('//text()'),2)

     : field name


partition by ,connect by prior 조합보다 훨씬 좋쿠나.


 


참고 블로그 : http://impudence99.blog.me/10107940704

                  http://kin.naver.com/qna/detail.nhn?d1id=1&dirId=10205&docId=130772275&qb=b3JhY2xlIHhtbGVsZW1lbnQ=&enc=utf8§ion=kin&rank=1&search_sort=0&spq=0&pid=gDxMhF5Y7uGssvBON78ssc--221883&sid=TlxNhpEbXE4AABHMeg4

반응형