SELECT DISTINCT A.EMPLID , A.EMPL_RCD , A.CAL_RUN_ID , A.PAY_ENTITY , SEC.OPRID , C.NAME , %DateAdd(B.EFFDT, -1) , B.ACTION , B.COMPANY , B.ESTABID , F.CONTRACT_NUM FROM PS_GP_PYE_PRC_STAT A , PS_JOB B , PS_PERSON_NAME C , PS_GP_RSLT_PIN D , PS_GPFR_ILL_ROWPIN E , PS_CONTRACT_DATA F %Sql(GPFR_SECU_EMPLMT_SQL, A) AND B.EMPLID = A.EMPLID AND B.EMPLID = F.EMPLID AND C.EMPLID = A.EMPLID AND B.EMPL_RCD = A.EMPL_RCD AND F.CONTRACT_NUM = B.CONTRACT_NUM AND F.CONTRACT_END_DT <= A.PRD_END_DT AND F.CONTRACT_END_DT >= A.PRD_BGN_DT AND B.ACTION IN ('TER' , 'TWP' , ' RET' , 'LOF') AND A.EMPL_RCD = B.EMPL_RCD 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.PIN_NUM = E.PIN_NUM AND E.GPFR_ILL_ROW_ID = '55' AND D.CALC_RSLT_VAL = 1 UNION SELECT DISTINCT A.EMPLID , A.EMPL_RCD , A.CAL_RUN_ID , A.PAY_ENTITY , SEC.OPRID , C.NAME , %DateAdd(B.EFFDT, -1) , B.ACTION , B.COMPANY , B.ESTABID , F.CONTRACT_NUM FROM PS_GP_PYE_PRC_STAT A ,PS_GP_PYE_SEG_STAT SEG , PS_JOB B , PS_PERSON_NAME C , PS_GP_RSLT_PIN D , PS_GPFR_ILL_ROWPIN E , PS_WKF_CNT_TYPE F %Sql(GPFR_SECU_EMPLMT_SQL, A) AND B.EMPLID = A.EMPLID AND B.EMPL_RCD = A.EMPL_RCD AND B.ACTION IN ('XFR') AND C.EMPLID = A.EMPLID AND B.EMPLID = F.EMPLID AND F.EFFDT = ( SELECT MAX(F1.EFFDT) FROM PS_WKF_CNT_TYPE F1 WHERE F1.EMPLID = F.EMPLID AND F1.EFFDT < B.EFFDT) AND SEG.CAL_RUN_ID = A.CAL_RUN_ID AND SEG.EMPL_RCD = A.EMPL_RCD AND SEG.GP_PAYGROUP = A.GP_PAYGROUP AND SEG.CAL_ID = A.CAL_ID AND SEG.ORIG_CAL_RUN_ID = A.ORIG_CAL_RUN_ID AND B.EFFDT BETWEEN SEG.SEG_BGN_DT AND SEG.SEG_END_DT AND A.EMPL_RCD = B.EMPL_RCD 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.PIN_NUM = E.PIN_NUM AND E.GPFR_ILL_ROW_ID = '55' AND D.CALC_RSLT_VAL = 1
|