SELECT DISTINCT A.EMPLID , A.PERIOD_END_DATE , A.GP_PAYGROUP , A.BALANCE_GRP_NUM , A.GPSG_CPF_EMPLR_REF , A.CITIZENSHIP_STATUS FROM PS_GP_PYE_PRC_STAT C , PS_GP_PYE_SEG_STAT B , PS_GPSG_CPF_RSLTS A WHERE A.EMPLID = B.EMPLID AND A.CAL_RUN_ID = B.CAL_RUN_ID AND A.EMPL_RCD = B.EMPL_RCD AND A.GP_PAYGROUP = B.GP_PAYGROUP AND A.CAL_ID = B.CAL_ID AND A.ORIG_CAL_RUN_ID = B.ORIG_CAL_RUN_ID AND A.RSLT_SEG_NUM = B.RSLT_SEG_NUM AND B.EMPLID = C.EMPLID AND B.CAL_RUN_ID = C.CAL_RUN_ID AND B.EMPL_RCD = C.EMPL_RCD AND B.GP_PAYGROUP = C.GP_PAYGROUP AND B.CAL_ID = C.CAL_ID AND B.ORIG_CAL_RUN_ID = C.ORIG_CAL_RUN_ID AND B.PYE_CALC_STAT >= '60' AND C.CALC_TYPE = 'P' AND B.SEG_END_DT = ( SELECT MAX(B1.SEG_END_DT) FROM PS_GP_PYE_SEG_STAT B1 WHERE B1.EMPLID = B.EMPLID AND B1.CAL_RUN_ID = B.CAL_RUN_ID AND B1.EMPL_RCD = B.EMPL_RCD AND B1.GP_PAYGROUP = B.GP_PAYGROUP AND B1.CAL_ID = B.CAL_ID AND B1.ORIG_CAL_RUN_ID = B.ORIG_CAL_RUN_ID AND B1.RSLT_SEG_NUM = B.RSLT_SEG_NUM) AND B.GP_CALC_TS = ( SELECT MAX(B2.GP_CALC_TS) FROM PS_GP_PYE_SEG_STAT B2 WHERE B2.EMPLID = B.EMPLID AND B2.EMPL_RCD = B.EMPL_RCD AND B2.SEG_END_DT = B.SEG_END_DT AND B2.GP_PAYGROUP = B.GP_PAYGROUP AND B2.RSLT_SEG_NUM = B.RSLT_SEG_NUM AND B2.PYE_CALC_STAT >= '60')
|