SELECT B.OPRID , A.EMPLID , C.EMPL_RCD , C.DEPTID , C.SUPERVISOR_ID , C.REPORTS_TO , B.EMAILID FROM PS_PERSONAL_DATA A , PSOPRDEFN B , PS_JOB C WHERE A.EMPLID = C.EMPLID AND C.EMPL_RCD = ( SELECT MIN (C1.EMPL_RCD) FROM PS_JOB C1 WHERE C1.EMPLID = C.EMPLID AND C1.EFFDT = ( SELECT MAX(C2.EFFDT) FROM PS_JOB C2 WHERE C2.EMPLID = C1.EMPLID AND C2.EMPL_RCD = C1.EMPL_RCD AND C2.EFFDT <= %CurrentDateIn) AND C1.EFFSEQ = ( SELECT MAX(C3.EFFSEQ) FROM PS_JOB C3 WHERE C3.EMPLID = C1.EMPLID AND C3.EMPL_RCD = C1.EMPL_RCD AND C3.EFFDT = C1.EFFDT)) AND C.EFFDT = ( SELECT MAX(C4.EFFDT) FROM PS_JOB C4 WHERE C4.EMPLID = C.EMPLID AND C4.EMPL_RCD = C.EMPL_RCD AND C4.EFFDT <= %CurrentDateIn) AND C.EFFSEQ = ( SELECT MAX(C5.EFFSEQ) FROM PS_JOB C5 WHERE C5.EMPLID = C.EMPLID AND C5.EMPL_RCD = C.EMPL_RCD AND C5.EFFDT = C.EFFDT) AND A.EMPLID = B.EMPLID AND C.EMPL_STATUS = 'A'
|