SELECT A.LM_PERSON_ID, B.FIRST_NAME, B.LAST_NAME, E.LM_EMAIL_ADDR FROM PS_LM_PERSON A LEFT OUTER JOIN PS_LM_PERS_EML_VW E ON A.LM_PERSON_ID = E.LM_PERSON_ID, PS_LM_PERSON_NAME B WHERE B.LM_PERSON_ID = A.LM_PERSON_ID AND B.LM_DISPLAY_FLAG = 'Y' AND %CurrentDateIn BETWEEN B.EFFDT AND B.LM_END_EFFDT AND ((B.LM_NAME_TYPE = 'PRF') OR (B.LM_NAME_TYPE = 'PRI' AND NOT EXISTS (SELECT P.LM_NAME_TYPE FROM PS_LM_PERSON_NAME P WHERE P.LM_PERSON_ID = B.LM_PERSON_ID AND P.LM_NAME_TYPE = 'PRF' AND %CurrentDateIn BETWEEN P.EFFDT AND P.LM_END_EFFDT)))
|