SELECT A.EMPLID , %Substring(A.USER_KEY1, 1, 3) , B.CALYEAR , %Substring(A.USER_KEY2, 1, 5) , MAX(A.SLICE_END_DT) FROM PS_GP_RSLT_ACUM A , PS_GPES_SYS_CALEND B , PS_GP_RSLT_PIN D , PS_GPES_SYS_CALEND X WHERE A.ACM_THRU_DT BETWEEN B.GPES_MONTH_BGN_DT AND B.GPES_MONTH_END_DT AND A.SLICE_END_DT BETWEEN X.GPES_MONTH_BGN_DT AND X.GPES_MONTH_END_DT AND X.CALYEAR = B.CALYEAR AND D.EMPLID = A.EMPLID AND D.CAL_RUN_ID = A.CAL_RUN_ID AND D.EMPL_RCD = A.EMPL_RCD AND D.GP_PAYGROUP = A.GP_PAYGROUP AND D.CAL_ID = A.CAL_ID AND D.ORIG_CAL_RUN_ID = A.ORIG_CAL_RUN_ID AND D.RSLT_SEG_NUM = A.RSLT_SEG_NUM AND D.PIN_NUM = ( SELECT PIN_NUM FROM PS_GP_PIN WHERE PIN_CODE = 'SS VR HC RUN TYPE ESP') AND D.SLICE_BGN_DT = A.SLICE_BGN_DT AND D.SLICE_END_DT = A.SLICE_END_DT AND D.CHR_PIN_VAL = 'MENSUAL' GROUP BY A.EMPLID, A.USER_KEY1, B.CALYEAR, A.USER_KEY2
|