SELECT A.EMPLID ,A.EMPL_RCD ,CASE WHEN R.LASTUPDDTTM IS NOT NULL AND R.LASTUPDDTTM >= A.LASTUPDDTTM THEN R.LASTUPDDTTM WHEN R.LASTUPDDTTM IS NOT NULL AND A.LASTUPDDTTM >= R.LASTUPDDTTM THEN A.LASTUPDDTTM WHEN R.LASTUPDDTTM IS NULL THEN A.LASTUPDDTTM END FROM ((PS_JOB A LEFT OUTER JOIN PS_HR_RW_IDX_CTL R ON A.EMPLID=R.EMPLID AND A.EMPL_RCD=R.EMPL_RCD ) ) WHERE A.EFFDT = ( SELECT MAX(A_ED.EFFDT) FROM PS_JOB A_ED WHERE A.EMPLID = A_ED.EMPLID AND A.EMPL_RCD = A_ED.EMPL_RCD AND A_ED.EFFDT <= %CurrentDateIn) AND A.EFFSEQ = ( SELECT MAX(A_ES.EFFSEQ) FROM PS_JOB A_ES WHERE A.EMPLID = A_ES.EMPLID AND A.EMPL_RCD = A_ES.EMPL_RCD AND A.EFFDT = A_ES.EFFDT) AND A.HR_STATUS='A'
|