SELECT OPRID ,RUN_CNTL_ID FROM PS_GPCH_RC_PAYROLL WHERE EXISTS ( SELECT A.GPCH_EG_DOMAINID FROM PS_GPCH_EG_DSET A WHERE A.GPCH_EG_DOMAINID = PS_GPCH_RC_PAYROLL.GPCH_EG_DOMAINID AND A.COMPANY = PS_GPCH_RC_PAYROLL.COMPANY AND A.EFFDT = ( SELECT MAX(A_ED.EFFDT) FROM PS_GPCH_EG_DSET A_ED WHERE A.COMPANY = A_ED.COMPANY AND A.GPCH_EG_DOMAINID = A_ED.GPCH_EG_DOMAINID AND A_ED.EFFDT <= %CurrentDateIn) AND A.GPCH_EG_DOMAINID IN ( SELECT B.GPCH_EG_DOMAINID FROM PS_GPCH_EG_DSETDTL B WHERE A.COMPANY = B.COMPANY AND A.GPCH_EG_DOMAINID = B.GPCH_EG_DOMAINID AND A.EFFDT = B.EFFDT AND (B.GPCH_SI_PROV_TYPE IN ('A','C','E','I') OR ( B.GPCH_SI_PROV_TYPE = '9' AND A.GPCH_EG_VERSION = '5') OR ( B.GPCH_SI_PROV_TYPE = '5' AND B.GPCH_FK_MODE <> '0') OR ( B.GPCH_SI_PROV_TYPE = '6' AND B.GPCH_FK_MODE = '4') OR ( B.GPCH_SI_PROV_TYPE = '7' AND B.GPCH_FK_MODE = '4')))) OR (GPCH_EG_DOMAINID=0 AND USED_BY = 'M')
|