SELECT B.OPRID , B.EMPLID , A.NAME FROM %Table(PSOPRDEFN) B , %Table(PERSONAL_DATA) A , %Table(JOB) C WHERE A.EMPLID = B.EMPLID AND A.EMPLID = C.EMPLID AND C.EMPL_STATUS = 'A' AND C.EMPL_RCD = ( SELECT MIN (C3.EMPL_RCD) FROM PS_JOB C3 WHERE C3.EMPLID = C.EMPLID AND C3.EFFDT = ( SELECT MAX(C31.EFFDT) FROM PS_JOB C31 WHERE C31.EMPLID = C3.EMPLID AND C31.EMPL_RCD = C3.EMPL_RCD AND C31.EFFDT <= %CurrentDateIn) AND C3.EFFSEQ = ( SELECT MAX(C32.EFFSEQ) FROM PS_JOB C32 WHERE C32.EMPLID = C3.EMPLID AND C32.EMPL_RCD = C3.EMPL_RCD AND C32.EFFDT = C3.EFFDT)) AND C.EFFDT = ( SELECT MAX(C1.EFFDT) FROM PS_JOB C1 WHERE C1.EMPLID = C.EMPLID AND C1.EMPL_RCD = C.EMPL_RCD AND C1.EFFDT <= %CurrentDateIn) AND C.EFFSEQ = ( SELECT MAX(C2.EFFSEQ) FROM PS_JOB C2 WHERE C2.EMPLID = C.EMPLID AND C2.EMPL_RCD = C.EMPL_RCD AND C2.EFFDT = C.EFFDT)
|