Saturday, January 15, 2011

What is the difference between Sub-Query & Co-Related Sub-Query?

What is the difference between Sub-Query & Co-Related Sub-Query?
Answers:

When queries are written in a nested manner then it is termed as a sub-query. A Sub-Query get executed once for the parent statement whereas Co-Related Sub-Query get executed once for each row of the parent query.

Select Empname, Deptno, Salary from Employee Emp where Salary = (Select Max(Salary) from Employee where Deptno = Emp.Deptno) order by Deptno

No comments:

Post a Comment