SELECT C.ACA_DAT_EXTRACT_ID ,C.ACA_ALE_MEMBER ,C.ACA_CALENDAR_YEAR ,C.EMPLID ,0 ,NM.NAME FROM PS_ACA_EMP_MO_CH4D C , PS_NAMES NM WHERE C.ACA_DATA_STATUS IN ('E','I','U','W','M') AND NM.EMPLID = C.EMPLID AND NM.NAME_TYPE = 'PRI' AND NM.EFF_STATUS = 'A' AND NM.EFFDT = ( SELECT MAX(NM1.EFFDT) FROM PS_NAMES NM1 WHERE NM.EMPLID = NM1.EMPLID AND NM.NAME_TYPE = NM1.NAME_TYPE AND NM1.EFFDT <= %CurrentDateIn) UNION SELECT C.ACA_DAT_EXTRACT_ID ,C.ACA_ALE_MEMBER ,C.ACA_CALENDAR_YEAR ,C.EMPLID ,0 ,NM.NAME FROM PS_ACA_EMP_MO_AMTD C , PS_NAMES NM WHERE C.ACA_DATA_STATUS IN ('E','I','U','W','M') AND NM.EMPLID = C.EMPLID AND NM.NAME_TYPE = 'PRI' AND NM.EFF_STATUS = 'A' AND NM.EFFDT = ( SELECT MAX(NM1.EFFDT) FROM PS_NAMES NM1 WHERE NM.EMPLID = NM1.EMPLID AND NM.NAME_TYPE = NM1.NAME_TYPE AND NM1.EFFDT <= %CurrentDateIn) UNION SELECT C.ACA_DAT_EXTRACT_ID ,C.ACA_ALE_MEMBER ,C.ACA_CALENDAR_YEAR ,C.EMPLID ,0 ,NM.NAME FROM PS_ACA_DEP_MO_CH1D C , PS_NAMES NM WHERE C.ACA_DATA_STATUS IN ('E','I','U','W','M') AND NM.EMPLID = C.EMPLID AND NM.NAME_TYPE = 'PRI' AND NM.EFF_STATUS = 'A' AND NM.EFFDT = ( SELECT MAX(NM1.EFFDT) FROM PS_NAMES NM1 WHERE NM.EMPLID = NM1.EMPLID AND NM.NAME_TYPE = NM1.NAME_TYPE AND NM1.EFFDT <= %CurrentDateIn) UNION SELECT C.ACA_DAT_EXTRACT_ID ,C.ACA_ALE_MEMBER ,C.ACA_CALENDAR_YEAR ,C.EMPLID ,0 ,NM.NAME FROM PS_ACA_EMP_MO_C20D C , PS_NAMES NM WHERE C.ACA_DATA_STATUS IN ('E','I','U','W','M') AND NM.EMPLID = C.EMPLID AND NM.NAME_TYPE = 'PRI' AND NM.EFF_STATUS = 'A' AND NM.EFFDT = ( SELECT MAX(NM1.EFFDT) FROM PS_NAMES NM1 WHERE NM.EMPLID = NM1.EMPLID AND NM.NAME_TYPE = NM1.NAME_TYPE AND NM1.EFFDT <= %CurrentDateIn)
|