select * from qmd_territories where territoryid in () ---> select campaignid, campaignname from tbl_crm_campaigns where ownerid = and ownertype = and active = and campaignid in ( select distinct CampaignId from tbl_SPL_Opportunities where OwnerID = and ownertype = and CampaignId is not null ) order by campaignname
Sort Order