SELECT A.EMPLID
, A.EMPL_RCD
, A.CAL_RUN_ID
, A.GP_PAYGROUP
, A.CAL_ID
, A.ORIG_CAL_RUN_ID
, A.RSLT_SEG_NUM
, A.SEG_BGN_DT
, A.SEG_END_DT
,SUM(b.Day_count_paid)
,SUM(b.Day_count_unpaid)
FROM PS_GP_PYE_SEG_STAT A
, ps_gp_rslt_abs B
WHERE A.EMPLID = B.EMPLID
AND A.EMPL_RCD = B.EMPL_RCD
AND A.GP_PAYGROUP = B.GP_PAYGROUP
AND A.RSLT_SEG_NUM = b.RSLT_SEG_NUM
GROUP BY A.EMPLID , A.EMPL_RCD , A.CAL_RUN_ID , A.GP_PAYGROUP , A.CAL_ID , A.ORIG_CAL_RUN_ID , A.RSLT_SEG_NUM , A.SEG_BGN_DT , a.SEG_END_DT