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 ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between plan and package in db2?

569


How will you return the number of records in table?

514


Who uses db2?

573


Name the lockable units in DB2?

663


can we view the access paths created by dbrm ? how ? thx

6242






What r the comman abends in db2, jcl and cobol???????

1818


How can you find out the # of rows updated after an update statement?

637


How to connect to db2 database from windows command line?

562


What is copy pending status in db2?

636


What is the physical storage length of the data types: date, time, timestamp in the db2 database?

644


What is cloudant database?

641


What is rct?

751


What is load utility in db2?

665


What kind of database is db2?

569


What is the use of db2?

586