Correlated sub-query and nested sub-query examples

Please give some sub-query examples based on correlated sub-query and nested

Questions by manishayadav_1   answers by manishayadav_1

Showing Answers 1 - 4 of 4 Answers

nandlalseth

  • Aug 14th, 2008
 

Correlated Sub Query:
Select * from emp e where exists (select 1 from dept d where d.deptno = e.deptno)

Nested Sub Query:
Select * from emp e where deptno in (select deptno from dept d)

  Was this answer useful?  Yes

correlated:- outer query is executed first and result is sent to inner query for execution

       select * from emp e1 where e1.basicsal=(selcte max(basicsal) from emp e2 where e2.deptno=e1.deptno)

nested:- inner query is excuted first and result is sent to outer query for execution

       select * from emp where (deptno,basicsal) in (select deptno,max(basicsal) from emp group by deptno)

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions