SELECT A.DEPTID , A.EMPLID , A.EMPL_RCD , B.GP_PAYGROUP , B.PIN_NUM , B.CAL_RUN_ID , B.CAL_ID , SUM( B.CALC_RSLT_VAL) FROM PS_JOB A , PS_GP_RSLT_ACUM B 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.EMPLID = B.EMPLID AND A.EMPL_RCD = B.EMPL_RCD AND A.GP_PAYGROUP = B.GP_PAYGROUP AND B.RSLT_SEG_NUM = ( SELECT MAX(SUB.RSLT_SEG_NUM) FROM PS_GP_RSLT_ACUM SUB WHERE B.EMPLID = SUB.EMPLID AND B.CAL_RUN_ID = SUB.CAL_RUN_ID AND B.EMPL_RCD = SUB.EMPL_RCD AND B.GP_PAYGROUP = SUB.GP_PAYGROUP AND B.CAL_ID = SUB.CAL_ID AND B.ORIG_CAL_RUN_ID = SUB.ORIG_CAL_RUN_ID) ) GROUP BY A.DEPTID , A.EMPLID , A.EMPL_RCD , B.CAL_RUN_ID, B.GP_PAYGROUP , B.CAL_ID , B.PIN_NUM
|