Microsoft SQL Correlated Subquery
-- Correlated Subquries are inner subqueries that are dependant on the outer query
-- Correlated inner subquries cannot run or execute on their own
-- An example is where the correlated inner subquery is joined to the outer query
select product,
(select count(*) from [test].[dbo].[options on fx majorsii] as fx2
where fx2.[Product]=fx.[Product])
from [test].[dbo].[options on fx majors] as fx;

-- Correlated Subquries are inner subqueries that are dependant on the outer query
-- Correlated inner subquries cannot run or execute on their own
-- An example is where the correlated inner subquery is joined to the outer query
select product,
(select count(*) from [test].[dbo].[options on fx majorsii] as fx2
where fx2.[Product]=fx.[Product])
from [test].[dbo].[options on fx majors] as fx;
No comments:
Post a Comment