select distinct cdrS.ownerId, cdrS.fsl_tablecode, cdrS.fsl_dstId from tbl_CDR_Distributors cdrS with (nolock) inner join tbl_DST_Distributors dst with (nolock) on cdrS.fsl_dstId = dst.dstId inner join tbl_CDR_Distributors cdrB with (nolock) on cdrB.ownerId = cdrS.ownerId and cdrB.fsl_tablecode = cdrS.fsl_tablecode and cdrB.fsl_dstId = cdrS.fsl_dstId where cdrS.ownerId > 0 and cdrS.cdr_dstCompanyType = 'S' and nullif( cdrS.fsl_dstId, 0 ) is not null and cdrS.fsl_mapPriority = 1 and cdrB.cdr_dstCompanyType = 'B' and cdrB.fsl_mapPriority > 1