데이터가 없어서 확인이 안되니.. 상상코딩...
WITH TT AS( 원본쿼리 ) SELECT TT.* FROM TT WHERE (TRANSCODE, COMMENTTYPE) IN ( SELECT TRANSCODE, MAX(COMMENTTYPE) FROM (SELECT TT.TRANSCODE, DECODE(SS.VIEW_COMMENTTYPE,30,30,TT.COMMENTTYPE) COMMENTTYPE FROM TT LEFT OUTER JOIN ( SELECT TRANSCODE, COMMENTTYPE AS VIEW_COMMENTTYPE FROM TT WHERE COMMENTTYPE = 30 ) SS ON (TT.TRANSCODE = SS.TRANSCODE) ) GROUP BY TRANSCODE) ;