SELECT DISTINCT JOB.COMPANY , JOB.EFFDT , JOB.EMPLID , JOB.EMPL_RCD , NAM.NAME FROM PS_JOB JOB , PS_NAMES NAM WHERE JOB.EMPLID = NAM.EMPLID AND NAME_TYPE = 'PRI' AND NAM.EFFDT = ( SELECT MAX(NAM2.EFFDT) FROM PS_NAMES NAM2 WHERE NAM2.EMPLID = NAM.EMPLID AND NAM2.NAME_TYPE = NAM.NAME_TYPE AND EFFDT <= %CurrentDateIn) AND JOB.EFFDT = ( SELECT MAX(JOB3.EFFDT) FROM PS_JOB JOB3 WHERE JOB3.EMPLID = JOB.EMPLID AND JOB3.EMPL_RCD= JOB.EMPL_RCD AND JOB3.COMPANY = JOB.COMPANY) AND JOB.EFFSEQ = ( SELECT MAX(JOB2.EFFSEQ) FROM PS_JOB JOB2 WHERE JOB.EMPLID=JOB2.EMPLID AND JOB.EMPL_RCD=JOB2.EMPL_RCD AND JOB.COMPANY = JOB2.COMPANY AND JOB2.EFFDT<=JOB.EFFDT)
|