SELECT A.EMPLID , D.NAME FROM %Table(RS_WORKER_TBL) A , %Table(RS_WRKR_EFFDT) B , %Table(JOB) CD , %Table(PERSONAL_DATA) D , %Table(INSTALLATION_RS) F WHERE B.EMPLID = A.EMPLID AND B.SYSTEM_SOURCE = 'RS' AND A.EMPLID = D.EMPLID AND B.EFFDT = ( SELECT MAX(EF.EFFDT) FROM %Table(RS_WRKR_EFFDT) EF WHERE EF.EMPLID = B.EMPLID AND EF.SYSTEM_SOURCE = 'RS' AND EF.EFFDT <= %CurrentDateIn) AND B.WRKR_INELIGIBLE = 'N' AND CD.EMPLID = B.EMPLID AND CD.EMPL_RCD = B.EMPL_RCD AND CD.EFFDT = ( SELECT MAX(JB.EFFDT) FROM %Table(JOB) JB WHERE JB.EMPLID = CD.EMPLID AND JB.EMPL_RCD = CD.EMPL_RCD AND JB.EFFDT <= %CurrentDateIn) AND CD.EFFSEQ = ( SELECT MAX(JB2.EFFSEQ) FROM %Table(JOB) JB2 WHERE JB2.EMPLID = CD.EMPLID AND JB2.EMPL_RCD = CD.EMPL_RCD AND JB2.EFFDT = CD.EFFDT) AND CD.EMPL_STATUS = 'A' AND (F.NON_EMPL_STAFF = 'Y' OR (F.NON_EMPL_STAFF = 'N' AND D.PER_STATUS = 'E'))
|