SELECT SEC.OPRID , SEC .EMPLID , SEC .EMPL_RCD , B.CAL_RUN_ID , SEC.NAME FROM PS_EMPLMT_SRCH_GBL SEC , PS_GP_PYE_PRC_STAT A , PS_GP_PYE_SEG_STAT B , PS_GPFR_P_SLIP_GRP PSL WHERE A.GP_PAYGROUP = PSL.GP_PAYGROUP AND A.EMPLID = SEC.EMPLID AND A.EMPL_RCD = SEC.EMPL_RCD AND 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.CALC_TYPE = 'P' AND (A.PRD_TYPE = 'C' OR A.PRD_TYPE = 'R' AND NOT EXISTS ( SELECT 'X' FROM PS_GP_PYE_SEG_STAT C , PS_GP_PYE_PRC_STAT D WHERE C.EMPLID = D.EMPLID AND C.CAL_RUN_ID = D.CAL_RUN_ID AND C.EMPL_RCD = D.EMPL_RCD AND C.GP_PAYGROUP = D.GP_PAYGROUP AND C.CAL_ID = D.CAL_ID AND C.ORIG_CAL_RUN_ID = D.ORIG_CAL_RUN_ID AND D.CALC_TYPE = 'P' AND D.PRD_TYPE = 'C' AND C.EMPLID = A.EMPLID AND C.CAL_RUN_ID = A.CAL_RUN_ID AND C.EMPL_RCD = A.EMPL_RCD AND C.GP_PAYGROUP = A.GP_PAYGROUP AND C.PYMT_KEY1 = B.PYMT_KEY1 AND C.PYMT_KEY2 = B.PYMT_KEY2 AND C.PYMT_KEY3 = B.PYMT_KEY3 AND C.PYMT_KEY4 = B.PYMT_KEY4 ) AND B.RSLT_SEG_NUM = ( SELECT MIN(E.RSLT_SEG_NUM) FROM PS_GP_PYE_SEG_STAT E WHERE E.EMPLID = B.EMPLID AND E.CAL_RUN_ID = B.CAL_RUN_ID AND E.EMPL_RCD = B.EMPL_RCD AND E.GP_PAYGROUP = B.GP_PAYGROUP AND E.PYMT_KEY1 = B.PYMT_KEY1 AND E.PYMT_KEY2 = B.PYMT_KEY2 AND E.PYMT_KEY3 = B.PYMT_KEY3 AND E.PYMT_KEY4 = B.PYMT_KEY4 ) AND B.GP_CALC_TS = ( SELECT MAX(E.GP_CALC_TS) FROM PS_GP_PYE_SEG_STAT E WHERE E.EMPLID = B.EMPLID AND E.CAL_RUN_ID = B.CAL_RUN_ID AND E.EMPL_RCD = B.EMPL_RCD AND E.GP_PAYGROUP = B.GP_PAYGROUP AND E.PYMT_KEY1 = B.PYMT_KEY1 AND E.PYMT_KEY2 = B.PYMT_KEY2 AND E.PYMT_KEY3 = B.PYMT_KEY3 AND E.PYMT_KEY4 = B.PYMT_KEY4 ) )
|