SELECT DISTINCT JOB.EMPLID , JOB.EMPL_RCD , JOB.EFFDT , PREV.PREV_CODE_ITA , JOB.COMPANY , JOB.ESTABID , P.PREV_POS_CODE_ITA FROM PS_JOB JOB , PS_PREV_COMP_ITA PREV , PS_PREV_TBL_ITA P WHERE JOB.COMPANY = PREV.COMPANY AND (JOB.ESTABID = PREV.ESTABID OR PREV.ESTABID = ' ') AND JOB.EFFDT = ( SELECT MAX(JOB2.EFFDT) FROM PS_JOB JOB2 WHERE JOB.EMPLID=JOB2.EMPLID AND JOB2.EFFDT<=JOB.EFFDT) AND JOB.EFFSEQ = ( SELECT MAX(JOB2.EFFSEQ) FROM PS_JOB JOB2 WHERE JOB.EMPLID=JOB2.EMPLID AND JOB2.EFFDT<=JOB.EFFDT) AND P.PREV_CODE_ITA = PREV.PREV_CODE_ITA AND PREV.EFFDT = ( SELECT MAX(PREV2.EFFDT) FROM PS_PREV_COMP_ITA PREV2 WHERE PREV2.PREV_CODE_ITA = PREV.PREV_CODE_ITA AND JOB.COMPANY = PREV2.COMPANY AND (PREV.ESTABID = PREV2.ESTABID OR PREV2.ESTABID = ' ' ) AND PREV2.EFF_STATUS = 'A')
|