select distinct opr.ownerId, opr.fsltablecode, opr.operatorId, opr.fsl_choId from tbl_OPR_ClientOperators opr inner join tbl_IMPORT_Aliases a on a.ownerId = opr.ownerId and a.ownerType =opr.fsltablecode and a.objectId = opr.operatorId and a.objectType = 'OPR' inner join tbl_OPR_CLientOperators b on b.operatorId = convert( int, right( a.alias, len( a.alias ) - 14 )) and b.ownerId = 387 and b.fsltablecode = 'BRO' and nullif( b.fsl_choId, 0 ) is null where opr.ownerId = 207 and opr.fsltablecode = 'MFR' and opr.fsl_choId > 0 and a.alias like '%B:387;O%' order by opr.fsl_choId, opr.ownerId, opr.operatorId