select i.partnerType, i.interactionDate, ip.purposeName, coalesce( ip.purposeId, 0 ) purposeId, opr.OPRType, i.disposition
from tbl_CRM_interactions i with (nolock)
left outer join tbl_CRM_InteractionPurposes ip with (nolock)
on ip.purposeId = i.interactionPurposeId
and ip.ownerId = i.ownerId
and ip.ownerType = i.ownerType
inner join tbl_OPR_ClientOperators opr with (nolock)
on opr.operatorId = i.partnerId
and opr.ownerId = i.ownerId
and opr.fslTableCode = i.ownerType
and i.ownerId =
and i.ownerType =
and i.participantId is null
and i.dispositionUserId =
and i.partnerType = 'OPR'
and i.interactionDate >=
select * from qmd_salesCallAll
where disposition = '?'
select * from qmd_salesCallAll
where disposition <> '?'
and interactionDate between and
select * from qmd_salesCompleted
where purposeName ='Prospecting'
select * from qmd_salesCallStatus
where purposeId > 0
and purposeName ='Prospecting'
select * from qmd_prospectingCalls where interactionDate <
select * from qmd_prospectingCalls
where ( interactionDate >= )
select * from qmd_salesCompleted
where purposeName ='Pipeline'
select * from qmd_salesCompleted
where purposeName ='Pipeline'
and OPRType in ('C','D')
--->
--->
select * from qmd_salesCallStatus
where purposeId > 0
and purposeName ='Pipeline'
select * from qmd_pipelineCalls
where OPRType in ('A','B')
select * from qmd_pipelineCalls
where OPRType in ('C','D')
--->
select * from qmd_pipelineCalls where interactionDate <
select * from qmd_pipelineCalls
where ( interactionDate >= )
select * from qmd_pipelineCallsCD where interactionDate <
select * from qmd_pipelineCallsCD
where ( interactionDate >= or interactionDate is null )
--->
select * from qmd_salesCompleted
where purposeName ='Retention'
and OPRType in ('A','B')
select * from qmd_salesCompleted
where purposeName ='Retention'
and OPRType ='C'
select * from qmd_salesCompleted
where purposeName ='Retention'
and OPRType ='D'
select * from qmd_salesCallStatus
where purposeId > 0
and purposeName ='Retention'
select * from qmd_retentionCalls
where OPRType in ('A','B')
select * from qmd_retentionCalls
where OPRType = 'C'
select * from qmd_retentionCalls
where OPRType = 'D'
select * from qmd_retentionCallsAB where interactionDate <
select * from qmd_retentionCallsAB
where ( interactionDate >= )
select * from qmd_retentionCallsC where interactionDate <
select * from qmd_retentionCallsD where interactionDate <
select * from qmd_retentionCallsC
where ( interactionDate >= )
select * from qmd_retentionCallsD
where ( interactionDate >= )
select * from qmd_salesCallStatus where purposeId = 0 and partnerType = 'OPR'
select * from qmd_operatorCalls where interactionDate <
select * from qmd_operatorCalls
where ( interactionDate >= or interactionDate is null )
select * from qmd_salesCallStatus where purposeId = 0 and partnerType = 'CDR'
select * from qmd_distributorCalls where interactionDate <
select * from qmd_distributorCalls
where ( interactionDate >= or interactionDate is null )
--->