Could anyone clearly explain the diference between sub
query and correlated sub query?

Answer Posted / sriram

Correlated subquery runs once for each row selected by the
outer query. It contains a reference to a value from the
row selected by the outer query.

Nested subquery runs only once for the entire nesting
(outer) query. It does not contain any reference to the
outer query row.

For example

Correlated Subquery:

select e1.empname e1.basicsal e1.deptno from emp e1 where
e1.basicsal (select max(basicsal) from emp e2 where
e2.deptno e1.deptno)

Nested Subquery:

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



Please let me know if I am wrong...............

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can deadlocks be resolved?

540


Is db2 a mainframe database?

566


What is an instance database?

598


Is ibm db2 free?

573


What are db2 objects?

639






What is db2 bind?

636


What is the result of open cursor statement?

636


What is the syntax for seeing the columns and data types of a table in the db2 database?

576


What is consistency token in db2?

639


What is commit in db2?

592


What is the purpose of rollback and commit?

593


What is the picture clause of null indicator variable?

688


What is precompiler in db2?

585


Mention the length of physical storage of the given data types of db2 – date, timestamp, time

585


On which levels locks can be applied?

655