SELECT A.LM_CI_ID , ( SELECT MAX(X.LM_ROW_MAINT_DTTM) FROM PS_LM_ACT X WHERE X.LM_CI_ID = A.LM_CI_ID ) AS LM_ROW_MAINT_DTTM FROM PS_LM_CI_TBL A, PS_LM_CI_SEC_TBL B WHERE A.LM_CI_ID = B.LM_CI_ID AND A.LM_CI_STATUS = '10' AND %CurrentDateIn BETWEEN A.EFFDT AND A.LM_END_EFFDT AND B.EFFDT = A.EFFDT AND NOT EXISTS ( SELECT 'X' FROM PS_LM_ACT_SEC A2 , PS_LM_ACT A3 WHERE A3.LM_CI_ID = A.LM_CI_ID AND A2.LM_ACT_ID = A3.LM_ACT_ID AND A2.LM_LRNR_GROUP_ID = B.LM_LRNR_GROUP_ID ) AND EXISTS ( SELECT 'X' FROM PS_LM_ACT A1 , PS_LM_ACT_SEC A2 WHERE A1.LM_CI_ID = A.LM_CI_ID AND A1.LM_ACT_ID = A2.LM_ACT_ID )
|