SELECT DISTINCT A.LM_CI_ID ,A.LM_ACT_ID ,B.LM_LC_ID ,D.LM_PERSON_ID , E.LANGUAGE_CD , E.LM_DM_LONG_NM FROM PS_LM_ACT_CI_VW A , PS_LM_ACT_CI_LVW E , PS_LM_LC_VW B , PS_LM_ACT_SEC C , PS_LM_PERS_LGRP_VW D WHERE A.LM_ACT_STATUS='1' AND A.LM_ACT_ID=B.LM_ACT_ID AND A.LM_ACT_ID=E.LM_ACT_ID AND A.LM_ACT_ID = C.LM_ACT_ID AND C.LM_LRNR_GROUP_ID=D.LM_LRNR_GROUP_ID AND (A.LM_END_DT>=%CurrentDateIn OR A.LM_END_DT IS NULL) AND NOT EXISTS( SELECT 'X' FROM PS_LM_LC_VW E WHERE E.LM_ACT_ID=B.LM_ACT_ID AND E.LM_BAS_LC_TYPE IN('20','30')) AND B.LM_LC_ID=( SELECT MAX(F.LM_LC_ID) FROM PS_LM_LC_VW F WHERE A.LM_ACT_ID=F.LM_ACT_ID) AND ( (A.LM_LST_ENRL_START = 'Y' AND ((A.LM_START_DT IS NOT NULL AND %CurrentDateIn <= A.LM_START_DT) OR (A.LM_START_DT IS NULL AND ((A.LM_END_DT IS NOT NULL AND %CurrentDateIn <= A.LM_END_DT) OR A.LM_END_DT IS NULL)))) OR (A.LM_LST_ENRL_START <> 'Y' AND ((A.LM_LST_ENRL_DT IS NOT NULL AND %CurrentDateIn <= A.LM_LST_ENRL_DT) OR (A.LM_LST_ENRL_DT IS NULL AND ((A.LM_LST_ENRL_DAYS > 0 AND (A.LM_LST_ENRL_TYPE = '1' AND ((A.LM_START_DT IS NOT NULL AND %CurrentDateIn <= %DateAdd(A.LM_START_DT,A.LM_LST_ENRL_DAYS * -1)) OR (A.LM_START_DT IS NULL AND ((A.LM_END_DT IS NOT NULL AND %CurrentDateIn <= A.LM_END_DT) OR A.LM_END_DT IS NULL))) ) OR (A.LM_LST_ENRL_TYPE <> '1' AND ((A.LM_START_DT IS NOT NULL AND %CurrentDateIn <= %DateAdd(A.LM_START_DT,A.LM_LST_ENRL_DAYS)) OR (A.LM_START_DT IS NULL AND ((A.LM_END_DT IS NOT NULL AND %CurrentDateIn <= A.LM_END_DT) OR A.LM_END_DT IS NULL))) ) ) OR (A.LM_LST_ENRL_DAYS = 0 AND (((A.LM_END_DT IS NOT NULL AND %CurrentDateIn <= A.LM_END_DT) OR A.LM_END_DT IS NULL))) ) ) ) ))
|