when the subquery is no longer self contained , you need to have a connection between inner query and outer query that is why we use correlated queries which means It calculates for each line based on the data it receives from the outer query. for example use pubs data set and try this :
select title , [type] , price ,
(select avg(price) from dbo.titles as InnerQuery where InnerQuery.[type] = OuterQuery.[type]) as AVGPrice
from dbo.titles as OuterQuery
as a result you will have the average price of each book type