SELECT DISTINCT JOB.EMPLID , JOB.EMPL_RCD , JOB.EFFDT , INPS.INPS_CODE_ITA , JOB.COMPANY , JOB.ESTABID , I.INPS_POS_CD_ITA FROM PS_JOB JOB , PS_INPS_COMP_ITA INPS , PS_INPS_TBL_ITA I WHERE JOB.COMPANY = INPS.COMPANY AND (JOB.ESTABID = INPS.ESTABID OR INPS.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 INPS.INPS_CODE_ITA = I.INPS_CODE_ITA AND INPS.EFFDT = ( SELECT MAX(INPS2.EFFDT) FROM PS_INPS_COMP_ITA INPS2 WHERE INPS2.INPS_CODE_ITA = INPS.INPS_CODE_ITA AND JOB.COMPANY = INPS2.COMPANY AND (INPS.ESTABID = INPS2.ESTABID OR INPS2.ESTABID = ' ') AND INPS2.EFF_STATUS = 'A')
|