SELECT %Abs(A.BO_ID) , ROLE_TYPE_ID , NM.BO_NAME_DISPLAY , 0 FROM PS_BO_ROLE A , PS_BO_NAME NM WHERE ROLE_TYPE_ID IN (2,9, 11) AND A.BO_ID = NM.BO_ID AND NM.PRIMARY_IND = 'Y' AND NOT EXISTS ( SELECT 'X' FROM PS_RD_ACCT_TM_VW B WHERE A.BO_ID = B.BO_ID_2 AND A.ROLE_TYPE_ID = B.ROLE_TYPE_ID_2) AND (EXISTS ( SELECT 'X' FROM PS_BO_REL REL WHERE A.BO_ID = REL.BO_ID_2 AND A.ROLE_TYPE_ID = REL.ROLE_TYPE_ID_2 AND REL.ROLE_TYPE_ID_1 = 17) OR EXISTS ( SELECT 'X' FROM PS_RSP_TP_HEADER PLN WHERE A.BO_ID = PLN.BO_ID AND A.ROLE_TYPE_ID = PLN.ROLE_TYPE_ID) OR EXISTS ( SELECT 'X' FROM PS_RSF_LEAD LE WHERE A.BO_ID = LE.BO_ID_CUST AND A.ROLE_TYPE_ID = LE.ROLE_TYPE_ID_CUST) OR EXISTS ( SELECT 'X' FROM PS_RSF_OPPORTUNITY OPP WHERE A.BO_ID = OPP.BO_ID_CUST AND A.ROLE_TYPE_ID = OPP.ROLE_TYPE_ID_CUST) )
|