SELECT X.CUSTOMER_SETID , X.CUST_ID , X.DUNS_NUMBER , X.CCR_DUNS_PLUS4 FROM PS_CCR_VNDR_HDR H , PS_CCR_CUST_XREF X WHERE %Join(COMMON_KEYS, CCR_VNDR_HDR H, CCR_CUST_XREF X) AND H.SOURCE_SYSTEM = 'FED' AND H.FR_BUS_TYPE IN ('2','3') AND H.OM_COMPLETE = 'N' AND X.CUST_OBJ_TYPE = 'CUST' AND X.STATUS = 'A' UNION SELECT X.CUSTOMER_SETID , X.CUST_ID , X.DUNS_NUMBER , X.CCR_DUNS_PLUS4 FROM PS_CCR_CUST_XREF X WHERE X.SOURCE_SYSTEM = 'FED' AND X.CUST_OBJ_TYPE = 'CUST' AND X.STATUS = 'A' AND NOT EXISTS ( SELECT 'X' FROM PS_CCR_CUST_XREF X2 WHERE X2.DUNS_NUMBER = X.DUNS_NUMBER AND X2.CCR_DUNS_PLUS4 = X.CCR_DUNS_PLUS4 AND X2.SOURCE_SYSTEM = X.SOURCE_SYSTEM AND X2.CUSTOMER_SETID = X.CUSTOMER_SETID AND X2.CUST_ID = X.CUST_ID AND X2.CUST_OBJ_TYPE = 'DNS')
|