SELECT DISTINCT A.EMPLID ,A.EFFDT FROM PS_JOB A WHERE A.EFFSEQ = ( SELECT MAX(EFFSEQ) FROM PS_JOB WHERE EMPLID = A.EMPLID AND EMPL_RCD = A.EMPL_RCD AND EFFDT = A.EFFDT) AND NOT EXISTS ( SELECT 'X' FROM PS_JOB B WHERE B.EMPLID = A.EMPLID AND B.EMPL_RCD = A.EMPL_RCD AND B.EFFDT = ( SELECT MAX(EFFDT) FROM PS_JOB WHERE EMPLID = B.EMPLID AND EMPL_RCD = B.EMPL_RCD AND EFFDT < A.EFFDT) AND B.EFFSEQ = ( SELECT MAX(EFFSEQ) FROM PS_JOB WHERE EMPLID = B.EMPLID AND EMPL_RCD = B.EMPL_RCD AND EFFDT = B.EFFDT) AND B.JOB_INDICATOR = A.JOB_INDICATOR AND ((B.EMPL_STATUS IN('A','L','P','S','W') AND A.EMPL_STATUS IN('A','L','P','S','W')) OR (B.EMPL_STATUS NOT IN('A','L','P','S','W') AND A.EMPL_STATUS NOT IN('A','L','P','S','W'))))
|