SELECT DISTINCT P.PAY_ENTITY ,J.EMPLID ,PD.FIRST_NAME ,PD.LAST_NAME , D.NATIONAL_ID FROM PS_JOB J ,PS_GP_PYGRP P , PS_PERSON_NAME PD , PS_PERS_NID D WHERE J.EFFDT=( SELECT MAX(J1.EFFDT) FROM PS_JOB J1 WHERE J1.EMPLID=J.EMPLID AND J1.EMPL_RCD=J.EMPL_RCD AND J1.EFFDT<=%DateAdd(%CurrentDateIn,30)) AND J.EFFSEQ=( SELECT MAX(J2.EFFSEQ) FROM PS_JOB J2 WHERE J2.EMPLID=J.EMPLID AND J2.EMPL_RCD=J.EMPL_RCD AND J2.EFFDT=J.EFFDT) AND J.EMPLID = PD.EMPLID AND P.GP_PAYGROUP=J.GP_PAYGROUP AND D.EMPLID=J.EMPLID AND D.COUNTRY = 'GBR' AND D.NATIONAL_ID_TYPE = 'PR_9'
|