select distinct i.interactionDate, i.interactionId, i.contactId, cdr.cdr_recordId, ip.linkId ipLinkId, isd.interactionDetailId, s.skuId, p.prodId, opr.operatorId, coalesce( isd.annualCaseAmt, 0 ) annualCaseAmt, p.product, p.shortDesc, s.sku, s.skuDesc, opr.companyName from tbl_BCRM_Objectives o inner join tbl_BCRM_ObjectiveTrgLink t on t.objectiveId = o.objectiveId inner join tbl_CRM_interactionParticipants ip on ip.participantId = t.linkId inner join tbl_CRM_Interactions i on i.interactionId = ip.interactionId inner join tbl_CRM_interactionSaleDetails isd on isd.interactionId = i.interactionId inner join tbl_PRD_Skus s on s.skuId = isd.saleSubjectId and s.discontinued = 'N' and s.crmActive = 'Y' inner join tbl_PRD_Products p on p.prodId = s.prodId inner join tbl_OPR_CLientOperators opr on opr.operatorId = i.partnerId and opr.crmActive = 'Y' left outer join tbl_CDR_Distributors cdr on cdr.cdr_recordId = i.cdrDistributorId and cdr.ownerId = i.ownerId and cdr.fsl_tablecode = i.ownertype where isd.saleSubjectType = 'SKU' and i.disposition = '?' and s.mfrId = and i.opportunityStageChangeId is null and i.partnerType = 'OPR' and isd.disposition in ( '?', 'FU' ) and o.objectiveId in ( ) and o.ownerId = and o.ownerType = 'BRO' and not exists ( select * from tbl_CRM_InteractionParticipants ip2 where ip2.linkId <> ip.linkId and ip2.interactionId = ip.interactionId ) order by i.interactionDate desc, i.interactionId Opportunity Created (#newOpportunityId#)
delete from tbl_CRM_interactionSaleDetails where interactionid = and interactionDetailId = and ownerId = and ownerType = 'BRO' Interaction Detail Deleted
select 1 as exist where exists ( select * from tbl_CRM_InteractionSaleDetails where interactionId = and ownerId = and ownerType = 'BRO' ) delete from tbl_CRM_interactions where interactionid = and ownerId = and ownerType = 'BRO' delete from tbl_CRM_InteractionParticipants where linkId = and interactionId = No more details, Interaction (#interactionId#) deleted
select 1 as exist where exists ( select * from tbl_CRM_interactionParticipants ip inner join tbl_BCRM_ObjectiveTrgLink t on t.linkId = ip.participantId where t.objectiveId = and t.targetType = 'OPR' and t.targetId = ) delete from tbl_BCRM_ObjectiveTrgLink where objectiveId = and targetType = 'OPR' and targetId = No more interactions, Operator (#operatorId#) removed as target
#opportunityCount# opportunities created