There are two types of sub queries :
1. Non correlated
2. Correlated
Correlated – This is a situation where the Sub Query uses a Col or more Col’s from the outer query for results
Select * from HumanResources.Employee as E
where exists
(
select * from HumanResources.EmployeeAddress EA
where E.EmployeeID=EA.EmployeeID
)
Non Correlated – This is a situation where the sub query doesn’t use the outer query Col or Col’s.
Select * from HumanResources.Employee as E
where E.EmployeeID IN
(Select EmployeeID
from HumanResources.EmployeeAddress
)