Merging scopes with joins