select distinct l.#_configField# flexFieldConfig from tbl_TER_TerritoryLevels l with (nolock) inner join tbl_TER_Territories t with (nolock) on t.levelId = l.levelId and t.ownerId = l.ownerId and t.fsl_tablecode = l.fsl_tablecode inner join tbl_CDR_Distributors cdr with (nolock) on cdr.cdr_territoryId = t.territoryId and cdr.fsl_tablecode = t.fsl_tablecode and cdr.ownerId = t.ownerId where cdr.ownerId = and cdr.fsl_tablecode = and cdr.cdr_recordId = inner join tbl_CDR_Distributors cdr with (nolock) on cdr.cdr_territoryId = t.territoryId and cdr.fsl_tablecode = t.fsl_tablecode and cdr.ownerId = t.ownerId inner join tbl_Fspro_members m with (nolock) on m.ownerId = cdr.ownerId and m.fsl_tablecode = cdr.fsl_tablecode and m.orgId = cdr.cdr_recordId and left( m.orgType, 3 ) = 'CDR' where m.ownerId = and m.fsl_tablecode = and m.fspro_userId = where t.ownerId = and t.fsl_tablecode = and t.territoryId in ( )