SELECT J.EMPLID , J.EFFDT , J_TLR.EFFDT , J.EMPL_RCD , J_TLR.EMPL_RCD , J.EFFSEQ , J_TLR.EFFSEQ , J.COMPANY , J_TLR.COMPANY , J.ACTION , J_TLR.ACTION FROM PS_JOB J , PS_JOB J_TLR WHERE J.EMPLID = J_TLR.EMPLID AND J.EMPL_RCD=J_TLR.EMPL_RCD AND (J_TLR.EFFDT =( SELECT MIN(EFFDT) FROM PS_JOB J_DT WHERE J_DT.EMPLID = J.EMPLID AND J_DT.EMPL_RCD = J.EMPL_RCD AND J_DT.EFFDT > J.EFFDT) AND J.EFFSEQ= ( SELECT MAX(J_SEQ.EFFSEQ) FROM PS_JOB J_SEQ WHERE J_SEQ.EMPLID=J.EMPLID AND J_SEQ.EMPL_RCD=J.EMPL_RCD AND J_SEQ.EFFDT=J.EFFDT) AND J_TLR.EFFSEQ=( SELECT MIN(J_SEQ1.EFFSEQ) FROM PS_JOB J_SEQ1 WHERE J_SEQ1.EMPLID = J.EMPLID AND J_SEQ1.EMPL_RCD = J.EMPL_RCD AND J_SEQ1.EFFDT = J_TLR.EFFDT)) AND J_TLR.COMPANY <> J.COMPANY AND J_TLR.ACTION NOT IN ('REH', 'HIR', 'ADD','RNW','ADL', 'ASG') UNION SELECT J.EMPLID , J.EFFDT , J_TLR.EFFDT , J.EMPL_RCD , J_TLR.EMPL_RCD , J.EFFSEQ , J_TLR.EFFSEQ , J.COMPANY , J_TLR.COMPANY , J.ACTION , J_TLR.ACTION FROM PS_JOB J , PS_JOB J_TLR WHERE J.EMPLID = J_TLR.EMPLID AND J.EMPL_RCD=J_TLR.EMPL_RCD AND J.EFFDT=J_TLR.EFFDT AND J.EFFSEQ = ( SELECT MAX(J_SEQ2.EFFSEQ) FROM PS_JOB J_SEQ2 WHERE J_SEQ2.EMPLID= J.EMPLID AND J_SEQ2.EMPL_RCD =J.EMPL_RCD AND J_SEQ2.EFFDT=J_TLR.EFFDT AND J_SEQ2.EFFSEQ J.COMPANY AND J_TLR.ACTION NOT IN ('REH', 'HIR', 'ADD','RNW','ADL', 'ASG')
|