SELECT B.ADMSIDO, C.ADMSGG, A.APPL_YMD, A.EGMINDNM, A.EGMOWNNM, A.EGMCOMAD, substr(max(sys_connect_by_path(A.CODE_CTN,' ')),2) as CODE_CTN, A.SRV, A.MET, substr(max(sys_connect_by_path(A.EQUIP,'/')),2) as EQUIP --잘모르겠음. FROM( ------ 요기부터. SELECT A.EGMDMNO, SUBSTR(A.EGMADMCD, 1, 2) AS SIDO, SUBSTR(A.EGMADMCD, 1, 5) AS SGG, A.APPL_YMD, A.EGMINDNM, A.EGMOWNNM, A.EGMCOMAD, C.CODE_CTN, D.SRV, D.MET, F.CODE_CTN || ', ' || TRUNC(E.SIZ,0) || G.CODE_CTN || ', ' || TRUNC(E.QT,0) AS EQUIP, ROW_NUMBER () over (partition by A.EGMDMNO order by C.CODE_CTN) rnum FROM EGM A LEFT JOIN CGG_RURPW B ON A.EGMDMNO = B.DMNO LEFT JOIN CODE C ON B.ABW_GBN = C.CODE AND C.CODE_ID = 'ENV325' LEFT JOIN CGG_RUR D ON A.EGMDMNO = D.DMNO LEFT JOIN CGG_TPBV E ON A.EGMDMNO = E.DMNO LEFT JOIN CODE F ON E.ABW_CAY_EQI_GBN = F.CODE AND F.CODE_ID = 'ENV332' LEFT JOIN CODE G ON E.UNT_CODE = G.CODE AND G.CODE_ID = 'CMM017' WHERE A.APPL_YMD BETWEEN '2004.01.01' AND '2004.12.31' --#조건1 AND SUBSTR(A.EGMADMCD, 1, 2) = '11' --#조건2 AND A.EGMDEPGBN = '37' AND NVL(A.DCB_YMD,'9999.99.99') = '9999.99.99' -------- 요기까지 따루하면 이상없음 ) A JOIN DMT_ADMCODE_SIDO B ON A.SIDO = B.SIDO_CODE JOIN DMT_ADMCODE_SGG C ON A.SGG = C.SGG_CODE START WITH rnum = 1 CONNECT BY PRIOR rnum = rnum - 1 GROUP BY B.ADMSIDO, C.ADMSGG, A.APPL_YMD, A.EGMINDNM, A.EGMOWNNM, A.EGMCOMAD, A.SRV, A.MET --ORDER BY B.SIDO_CODE, C.SGG_CODE 위와 같은 쿼리에서... 결과중, substr(max(sys_connect_by_path(A.CODE_CTN,' ')),2) as CODE_CTN, substr(max(sys_connect_by_path(A.EQUIP,'/')),2) as EQUIP 두개의 컬럼에 대해서만 중복 제거를 하고 싶습니다. 보여주는 결과에 ex> (폐기물,폐기물) ===> (폐기물) 로만 보여주려고 합니다. ====>>>> 요곳을 수정을 해주어야 하는지????? LEFT JOIN (select distinct code_ctn, code_id, code from CODE) C ON B.ABW_GBN = C.CODE and C.CODE_ID = 'ENV325' 어디를 수정해야 할지 잘 모르겠는데.... distinct를 사용할때의 위치를 어디에 넣어주어야 하는지.... 여기저기 넣어봤지만...중복제거가 되지 않더라구요 그리고, distinct이외의 다른 방법이 있는지... 혹시 인라인 뷰를 수정해야 한다면 어느 부분을 수정해야하는지좀 알려주세요... |