intersect a join- zadanie t-sql

0

mam za zadnie znaleźć wspólna lokalizacje dla pracowników i klientów:
używając intersect:
select country, region, city from hr.Employees
intersect
select country, region, city from sales.Customers
wychodzi:
UK NULL London
USA WA Kirkland
USA WA Seattle

używając join bądź podzapytania:

select distinct(e.country), e.region, e.city
from hr.Employees as e join sales.Customers as c
on e.region = c.region or e.region is null and c.region is null

select distinct(e.country), e.region, e.city
from hr.Employees as e
where exists (select *
from sales.Customers as c
where c.country =e.country)
wychodzi:
UK NULL London
USA WA Kirkland
USA WA Redmond
USA WA Seattle
USA WA Tacoma

czemu jest o dwa wiersze więcej ?gdzie jest błąd?

1

Zwróć uwagę na warunek sprzężenia, ten or bez nawiasów grupujących powoduje różnice. Wyświetl pola z customers to zobaczysz.

1 użytkowników online, w tym zalogowanych: 0, gości: 1