| SQL |
select sub.ownerId as targetMfrId, sub.subscriberId as targetBrokerId
from tbl_PRD_Subscriptions sub with (nolock)
left outer join tblManufacturers mfr with (nolock)
on sub.ownerId = mfr.mfr_id
left outer join tbl_SMA_BrokerOfficeLink link with (nolock)
on sub.ownerId = link.mfr_id
and sub.subscriberId = link.brokerId
where sub.ownerType = 'MFR'
and sub.subscriberType = 'BRO'
and sub.subscriberId <> 2661
and link.brokerId is null
and mfr.mfr_name is not null
order by sub.ownerId, sub.subscriberId |