Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

What is Correlated subquery

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
ensameer

New User


Joined: 15 Mar 2005
Posts: 4
Location: Chennai

PostPosted: Wed Mar 16, 2005 2:26 pm    Post subject: What is Correlated subquery
Reply with quote

What is Correlated Subquery ?
-Sameer
Back to top
View user's profile Send private message

i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Wed Mar 16, 2005 2:42 pm    Post subject:
Reply with quote

hi sameer,

in correlated subquery the outer query is executed first and depending on the result of it for each and every record the inner query is executed.


Cheers............

pavan
Back to top
View user's profile Send private message
ovreddy

Active User


Joined: 06 Dec 2004
Posts: 211
Location: Keane Inc., Minneapolis USA.

PostPosted: Wed Mar 16, 2005 6:28 pm    Post subject: Re: correlated subquery
Reply with quote

Hi,

Correlated sub query is a type of sub query in which Outer Query is executed at once (fetches one row) and by taking that values inner query will be executed for all rows. Then outer query fetches 2nd row then inner query will be executed for all rows and so on.

To clearly under stand see the following example which finds nth max sal

SELECT SAL FROM EMP A WHERE N = (SELECT COUNT(*) FROM EMP B WHERE A.SAL<=B.SAL);

Outer Query fetches 1 row and inner query compares it with all salaries. Then outer query fetches 2nd row and so on.

Thanks,
Reddy.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Subquery inside a Updatable cursor in... easebourne_ironfist DB2 8 Wed Jun 12, 2013 2:02 pm
No new posts Can we have correlated subquery in De... saurabh_24jul COBOL Programming 13 Fri Oct 28, 2011 10:59 pm
No new posts delete duplicate records using a subq... l.nethaji DB2 5 Thu Nov 25, 2010 2:13 pm
This topic is locked: you cannot edit posts or make replies. Difference between Corrrelated Subque... Sudeshna Sarkar DB2 2 Sat May 15, 2010 3:18 pm
No new posts Upadate specific columns using Co-rel... Learncoholic DB2 8 Tue May 11, 2010 12:35 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us