MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Co-related sub query

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
WHITE
Beginner


Joined: 03 Sep 2004
Posts: 8
Topics: 4

PostPosted: Fri Feb 18, 2005 7:39 pm    Post subject: Co-related sub query Reply with quote

Hi, I was practising on SQL to improve my grip over that. In that respect, I am trying to write a Corelated subquery, Following is the Query

SELECT
TA.REQUEST_NUM
FROM
ABCK.WO_REQUEST TA
WHERE 10 = (SELECT COUNT (TB.WO_REQUEST_NUM)
FROM
ABCK.WO_REQUEST TB
WHERE TA.WO_REQUEST_NUM > TB.WO_REQUEST_NUM) ;

I was expecting 10 Highest number of rows from the above query, But I was getting only one row from this.

When I changed the Inner select where clause to the following, I am still getting one row but a different than what I got earlier.

TB.WO_REQUEST_NUM > TA.WO_REQUEST_NUM


My assumption is that, for each row of the outer table , we will scan all the rows of the inner table (Though both are one table. DB2 will treat that as two tables as it will make two copies of the same table) and collect 10 maximum rows and display that on the screen.

Is my assumption right ?

Could you some one throw light on this one?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group