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 

selecting first two rows

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


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Thu May 26, 2005 7:56 am    Post subject: selecting first two rows Reply with quote

Hi,

I have a table of 100 rows. How to fetch only the first two rows using the select statement. I should not use any functions like count(*). there is no any condition to fetch rows. it is simple select statment.

pls. help me out.

Thanks in advance
nadh
Back to top
View user's profile Send private message Send e-mail
schintala
Beginner


Joined: 18 May 2005
Posts: 108
Topics: 31
Location: USA

PostPosted: Thu May 26, 2005 7:58 am    Post subject: Reply with quote

Did you try using the clause FETCH FIRST 2 ROWS ONLY in select statement. I guess it works. Try it out.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Thu May 26, 2005 8:08 am    Post subject: Reply with quote

nadh,

*sigh* ! you are on route to loose your privileges to post on this board.

http://mvsforums.com/helpboards/viewtopic.php?t=443&highlight=fetch+first

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nadh
Intermediate


Joined: 08 Oct 2004
Posts: 192
Topics: 89

PostPosted: Fri May 27, 2005 3:31 am    Post subject: Reply with quote

Kolusu,

Thankyou.

But, I know with FETCH FIRST 2 ROWS ONLY it works. But i want to retrieve the first two rows without using FETCH statement in SELECT. I should not use even count(*). Without using these things Is there any way to get first 2 rows from table? I can use subqueries.

Thanks in advance.
nadh
Back to top
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Fri May 27, 2005 7:21 am    Post subject: Reply with quote

nadh,

Can you tell me the reason as to why there are so many restrictions to just fetch 2 rows? Is this an interview question? If it was a real requirement, then please enlighten me as to why you cannot use fetch first clause with select or even count(*) function.

If this is indeed an interview question then here is the answer.

In spufi you have the option of setting the max select rows.

Code:

MAX SELECT LINES  ===>    2


Just change that to 2 and run the select query in spufi , and you will get the 2 rows.

I can't believe that an interviewer is expecting such an answer.

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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