Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / 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

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

Answer / praveen

if we want to select 100th hig no.
in sub-query we will write 100 conditions.
to avoid this we go for correlated sub-query

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More DB2 Interview Questions

SQLCODE = -199, ERROR: ILLEGAL USE OF KEYWORD CHAR, TOKEN KEY was expected

0 Answers  


What is the difference between SYNONYM and ALIAS?

6 Answers   TCS,


What is db2 connect?

0 Answers  


What is the SQL Communications Area and what are some of its key fields?

1 Answers  


what is consistency token

3 Answers  


How to compare data between two tables in db2?

0 Answers  


How can you do the explain of a dynamic sql statement?

0 Answers  


What is netezza database?

0 Answers  


i have table agdet i want first 5 maximum commission which query will you write for this thanks in advance

3 Answers  


what is utility for parm lib

0 Answers   IBM,


how will you retrieve first record in table

1 Answers   UST,


What is UNION,UNION ALL?

2 Answers  


Categories