SELECT A.EMPLID , A.CAL_RUN_ID , A.EMPL_RCD , A.GP_PAYGROUP , A.CAL_ID , A.RSLT_SEG_NUM , D.BANK_CD , D.ACCOUNT_EC_ID , D.ROLL_NUMBER FROM PS_GP_PYE_SEG_STAT A , PS_GP_CAL_RUN_DTL B , PS_GP_NET_DIST_DTL C , PS_PYE_BANKACCT D WHERE A.EMPLID = D.EMPLID AND D.EFF_STATUS = 'A' AND D.ACCOUNT_ID = C.ACCOUNT_ID AND C.EMPLID = A.EMPLID AND C.EMPL_RCD = A.EMPL_RCD AND A.GP_PAYGROUP = B.GP_PAYGROUP AND A.CAL_ID = B.CAL_ID AND A.EMPLID = C.EMPLID AND C.PRIMARY_ACCT_IND = 'Y' AND A.EMPL_RCD = C.EMPL_RCD AND C.EFFDT = ( SELECT MAX(C_ED.EFFDT) FROM PS_GP_NET_DIST_DTL C_ED WHERE C.EMPLID = C_ED.EMPLID AND C.EMPL_RCD = C_ED.EMPL_RCD AND C.RUN_TYPE = C_ED.RUN_TYPE AND C_ED.EFFDT <= B.PYMT_DT) AND (B.RUN_TYPE = C.RUN_TYPE OR (C.RUN_TYPE = ( SELECT E.RUN_TYPE FROM PS_GP_NET_DIST E WHERE C.EMPLID = E.EMPLID AND C.EMPL_RCD = E.EMPL_RCD AND E.DEFAULT_IND = 'Y') AND NOT EXISTS ( SELECT 'X' FROM PS_GP_NET_DIST_DTL WHERE EMPLID = C.EMPLID AND EMPL_RCD = C.EMPL_RCD AND RUN_TYPE = B.RUN_TYPE AND INSTANCE = C.INSTANCE)))
|