SELECT H.* FROM (SELECT G.* ,ROW_NUMBER() OVER(PARTITION BY G.TOP_MENU_CD ORDER BY G.TOP_MENU_ORD, G.MID_MENU_ORD, G.MENU_ORD) ROWNUM1 ,COUNT(*) OVER(PARTITION BY G.TOP_MENU_CD) AS CNT1 ,ROW_NUMBER() OVER(PARTITION BY G.TOP_MENU_CD, G.MID_MENU_CD ORDER BY G.TOP_MENU_ORD, G.MID_MENU_ORD, G.MENU_ORD) AS ROWNUM2 ,COUNT(*) OVER(PARTITION BY G.TOP_MENU_CD, G.MID_MENU_CD) AS CNT2 FROM (SELECT F.TOP_MENU_NM ,F.MID_MENU_NM ,F.MENU_NM ,F.MENU_CNT ,F.RECENT_DATE ,F.TOP_MENU_CD ,F.MID_MENU_CD ,F.MENU_CD ,F.TOP_MENU_ORD ,NVL(F.MID_MENU_ORD, 0) AS MID_MENU_ORD ,NVL(F.MENU_ORD, 0) AS MENU_ORD FROM (SELECT B.TOP_MENU_CD ,C.MENU_NM AS TOP_MENU_NM ,C.MENU_ORD AS TOP_MENU_ORD ,B.MID_MENU_CD ,D.MENU_NM AS MID_MENU_NM ,D.MENU_ORD AS MID_MENU_ORD ,B.MENU_CD ,E.MENU_NM ,E.MENU_ORD ,B.MENU_CNT ,TO_CHAR(TO_DATE(B.RECENT_DATE, 'YYYYMMDDHH24MISS'), 'YYYY-MM-DD HH24:MI') AS RECENT_DATE FROM (SELECT A.TOP_MENU_CD ,A.MID_MENU_CD ,A.MENU_CD ,SUM(A.MENU_CNT) AS MENU_CNT ,MAX(TO_NUMBER(A.YMD || A.HMS)) AS RECENT_DATE ,A.LANG_CD FROM (SELECT MENU_CD AS TOP_MENU_CD ,0 AS MID_MENU_CD ,0 AS MENU_CD ,MENU_CNT ,YMD ,HMS ,LANG_CD FROM TB_AOS WHERE YMD BETWEEN #{sdate} AND #{edate} AND LANG_CD = #{G_LANG_CD} AND TOP_MENU_CD = 0 AND LOG_GUBUN = #{logGubun} UNION ALL SELECT TOP_MENU_CD ,MENU_CD AS MID_MENU_CD ,0 AS MENU_CD ,MENU_CNT ,YMD ,HMS ,LANG_CD FROM TB_AOS WHERE YMD BETWEEN #{sdate} AND #{edate} AND LANG_CD = #{G_LANG_CD} AND TOP_MENU_CD <![CDATA[ <> ]]> 0 AND MID_MENU_CD = 0 AND LOG_GUBUN = #{logGubun} UNION ALL SELECT TOP_MENU_CD ,MID_MENU_CD ,MENU_CD ,MENU_CNT ,YMD ,HMS ,LANG_CD FROM TB_AOS WHERE YMD BETWEEN #{sdate} AND #{edate} AND LANG_CD = #{G_LANG_CD} AND TOP_MENU_CD <![CDATA[ <> ]]> 0 AND MID_MENU_CD <![CDATA[ <> ]]> 0 AND LOG_GUBUN = #{logGubun}) A GROUP BY A.TOP_MENU_CD, A.MID_MENU_CD, A.MENU_CD, A.LANG_CD) B ,TB_BBOS C ,TB_BBOS D ,TB_BBOS E WHERE B.LANG_CD = C.LANG_CD (+) AND B.LANG_CD = D.LANG_CD (+) AND B.LANG_CD = E.LANG_CD (+) AND B.TOP_MENU_CD = C.MENU_CD (+) AND B.MID_MENU_CD = D.MENU_CD (+) AND B.MENU_CD = E.MENU_CD (+)) F ORDER BY F.TOP_MENU_ORD, F.MID_MENU_ORD, F.MENU_ORD) G) H ORDER BY H.TOP_MENU_ORD, H.MID_MENU_ORD, H.ROWNUM1, H.ROWNUM2, H.MENU_ORD
위의 JOIN쿼리를 RIGHT OUTER JOIN으로 바꾸고 싶은데..
알리아스 C D E 부분에서 OUTER JOIN으로 바꿔줬더니..에러가 납니다.
저렇게 1:1관계가 아닌 1:다 관계일 때 OUTER JOIN으로 어떻게 바꾸는지.. 조언 부탁드립니다.