SELECT L0.LM_CATG_ID , CASE WHEN L1.LM_CHLD_CATG_ID IS NOT NULL THEN L1.LM_CHLD_CATG_ID END , CASE WHEN L2.LM_CHLD_CATG_ID IS NOT NULL THEN L2.LM_CHLD_CATG_ID END , CASE WHEN L3.LM_CHLD_CATG_ID IS NOT NULL THEN L3.LM_CHLD_CATG_ID END , CASE WHEN L4.LM_CHLD_CATG_ID IS NOT NULL THEN L4.LM_CHLD_CATG_ID END , CASE WHEN L5.LM_CHLD_CATG_ID IS NOT NULL THEN L5.LM_CHLD_CATG_ID END , CASE WHEN L6.LM_CHLD_CATG_ID IS NOT NULL THEN L6.LM_CHLD_CATG_ID END , CASE WHEN L7.LM_CHLD_CATG_ID IS NOT NULL THEN L7.LM_CHLD_CATG_ID END , CASE WHEN L8.LM_CHLD_CATG_ID IS NOT NULL THEN L8.LM_CHLD_CATG_ID END , CASE WHEN L9.LM_CHLD_CATG_ID IS NOT NULL THEN L9.LM_CHLD_CATG_ID END FROM PS_INSTALLATION LEFT OUTER JOIN PS_LM_CATG_TBL L0 ON 1 = 1 LEFT OUTER JOIN PS_LM_CATG_REL_TBL L1 ON L0.LM_CATG_ID = L1.LM_CATG_ID LEFT OUTER JOIN PS_LM_CATG_REL_TBL L2 ON L1.LM_CHLD_CATG_ID = L2.LM_CATG_ID LEFT OUTER JOIN PS_LM_CATG_REL_TBL L3 ON L2.LM_CHLD_CATG_ID = L3.LM_CATG_ID LEFT OUTER JOIN PS_LM_CATG_REL_TBL L4 ON L3.LM_CHLD_CATG_ID = L4.LM_CATG_ID LEFT OUTER JOIN PS_LM_CATG_REL_TBL L5 ON L4.LM_CHLD_CATG_ID = L5.LM_CATG_ID LEFT OUTER JOIN PS_LM_CATG_REL_TBL L6 ON L5.LM_CHLD_CATG_ID = L6.LM_CATG_ID LEFT OUTER JOIN PS_LM_CATG_REL_TBL L7 ON L6.LM_CHLD_CATG_ID = L7.LM_CATG_ID LEFT OUTER JOIN PS_LM_CATG_REL_TBL L8 ON L7.LM_CHLD_CATG_ID = L8.LM_CATG_ID LEFT OUTER JOIN PS_LM_CATG_REL_TBL L9 ON L8.LM_CHLD_CATG_ID = L9.LM_CATG_ID WHERE NOT EXISTS ( SELECT 1 FROM PS_LM_CATG_REL_TBL X WHERE L0.LM_CATG_ID = X.LM_CHLD_CATG_ID)
|