SELECT DISTINCT JOB.EMPLID , JOB.EMPL_RCD , JOB.EFFDT , INPDAI.INPDAI_CODE_ITA , JOB.COMPANY , JOB.ESTABID , I.INPDAI_POS_CD_ITA FROM PS_JOB JOB , PS_INPDAI_COMP_ITA INPDAI , PS_INPDAI_TBL_ITA I WHERE JOB.COMPANY = INPDAI.COMPANY AND (JOB.ESTABID = INPDAI.ESTABID OR INPDAI.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 INPDAI.INPDAI_CODE_ITA = I.INPDAI_CODE_ITA AND INPDAI.EFFDT = ( SELECT MAX(INPDAI2.EFFDT) FROM PS_INPDAI_COMP_ITA INPDAI2 WHERE INPDAI2.INPDAI_CODE_ITA = INPDAI.INPDAI_CODE_ITA AND JOB.COMPANY = INPDAI2.COMPANY AND (INPDAI.ESTABID = INPDAI2.ESTABID OR INPDAI2.ESTABID = ' ') AND INPDAI2.EFF_STATUS = 'A')
|