Sunday, November 30, 2014

2 Where Claues with 1 Sub query using NOT IN notation


Select CompanyName From Customers
Where Country='usa'
and Region NOT IN (Select Region From Employees
Where Region IS NOT NULL )
Order By CompanyName;

--OR better to use not exists
Select CompanyName From Customers c
Where Country='usa'
AND Not Exists (select 1 From Employees e Where c.Region=e.Region)
Order By CompanyName;



No comments:

Post a Comment