SELECT DISTINCT A.EMPLID , A.EMPL_RCD , B.NAME , C.EMPLID_TO , OPRJOB.JOBCODE ,D.DEPTID , D.DESCR ,J.DESCR FROM PS_TL_OT_DATA A , PS_PERSON_NAME B , PS_TL_OT_STATUS C , PS_JOB OPRJOB , PS_DEPT_TBL D , PS_JOBCODE_TBL J WHERE A.EMPLID=B.EMPLID AND A.EMPLID=C.EMPLID AND A.EMPL_RCD=C.EMPL_RCD AND A.TL_SEQ_NUM=C.TL_SEQ_NUM AND C.CURRENT_STEP > 0 AND OPRJOB.EMPLID = A.EMPLID AND OPRJOB.EMPL_RCD = A.EMPL_RCD AND OPRJOB.EFFDT= ( SELECT MAX(OPRJOB2.EFFDT) FROM PS_JOB OPRJOB2 WHERE OPRJOB.EMPLID=OPRJOB2.EMPLID AND OPRJOB.EMPL_RCD=OPRJOB2.EMPL_RCD AND OPRJOB2.EFFDT<=%CurrentDateIn) AND OPRJOB.EFFSEQ= ( SELECT MAX(OPRJOB3.EFFSEQ) FROM PS_JOB OPRJOB3 WHERE OPRJOB.EMPLID=OPRJOB3.EMPLID AND OPRJOB.EMPL_RCD=OPRJOB3.EMPL_RCD AND OPRJOB.EFFDT=OPRJOB3.EFFDT ) AND D.SETID = OPRJOB.SETID_DEPT AND D.DEPTID = OPRJOB.DEPTID AND D.EFFDT= ( SELECT MAX(D2.EFFDT) FROM PS_DEPT_TBL D2 WHERE D.DEPTID = D2.DEPTID AND D.SETID=D2.SETID AND D2.EFFDT<=%CurrentDateIn AND D2.EFF_STATUS = 'A') AND J.SETID = OPRJOB.SETID_JOBCODE AND J.JOBCODE = OPRJOB.JOBCODE AND J.EFFDT= ( SELECT MAX(J2.EFFDT) FROM PS_JOBCODE_TBL J2 WHERE J.JOBCODE = J2.JOBCODE AND J.SETID=J2.SETID AND J2.EFFDT<=%CurrentDateIn AND J2.EFF_STATUS = 'A')
|