select opr.operatorId, opr.ownerId, opr.fsltablecode, opr.fsl_choId, opr.companyName, opr.mfrCustNum, cdr.fsl_dstId
from tbl_OPR_ClientOperators opr with (nolock)
inner join tbl_CDR_Distributors cdr
on cdr.cdr_recordId = opr.distrib1
and cdr.ownerId = opr.ownerId
and cdr.fsl_tablecode = opr.fsltablecode
where opr.fsltablecode = 'DST'
and opr.ownerId > 0
and opr.fsl_choId > 0
and nullif( opr.mfrCustNum, '' ) is not null
and exists (
select * from tbl_OPR_CLientOperators opr2 with (nolock)
inner join tbl_OPR_DistributionDetails dd with (nolock)
on dd.operatorId = opr2.operatorId
and dd.ownerId = opr2.ownerId
and dd.ownerType = opr2.fsltablecode
inner join tbl_CDR_Distributors cdr2 with (nolock)
on cdr2.cdr_recordId = dd.cdr_recordId
and cdr2.ownerId = dd.ownerId
and cdr2.fsl_tablecode = dd.ownerType
where opr2.fsltablecode = 'MFR' and opr2.ownerId > 0
and nullif( opr2.fsl_choId, 0 ) is null
and dd.accountNumber = opr.mfrCustNum
and cdr2.fsl_dstId = cdr.fsl_dstid
)
order by opr.ownerId