SELECT C.EMPLID , C.EMPL_RCD , C.GP_PAYGROUP , D.CAL_ID , C.PYMT_DT , D.CAL_RUN_ID , D.RSLT_SEG_NUM , C.PAY_ENTITY , D.SEG_BGN_DT , D.SEG_END_DT FROM PS_GP_PYE_PRC_STAT C , PS_GP_PYE_SEG_STAT D , PS_GP_RUN_TYPE GRT , PS_GP_CAL_RUN GPCAL WHERE C.CAL_RUN_ID = D.CAL_RUN_ID AND D.CAL_RUN_ID = D.ORIG_CAL_RUN_ID AND D.CAL_RUN_ID = GPCAL.CAL_RUN_ID AND GPCAL.COUNTRY = 'THA' AND C.EMPLID = D.EMPLID AND C.EMPL_RCD = D.EMPL_RCD AND C.GP_PAYGROUP = D.GP_PAYGROUP AND C.CAL_ID = D.CAL_ID AND C.RUN_TYPE = GRT.RUN_TYPE AND GRT.CALC_TYPE = 'P' AND D.RSLT_REV_NUM = ( SELECT MIN(RSLT_REV_NUM) FROM PS_GP_PYE_SEG_STAT D1 WHERE D.EMPLID = D1.EMPLID AND D.CAL_RUN_ID = D1.CAL_RUN_ID AND D.EMPL_RCD = D1.EMPL_RCD AND D.GP_PAYGROUP = D1.GP_PAYGROUP AND D.CAL_ID = D1.CAL_ID AND D.RSLT_SEG_NUM = D1.RSLT_SEG_NUM ) AND D.PYE_CALC_STAT IN ('60', '65', '70','75')
|