View previous topic :: View next topic |
Author |
Message |
nadh Intermediate
Joined: 08 Oct 2004 Posts: 192 Topics: 89
|
Posted: Thu May 26, 2005 7:56 am Post subject: selecting first two rows |
|
|
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 |
|
 |
schintala Beginner
Joined: 18 May 2005 Posts: 108 Topics: 31 Location: USA
|
Posted: Thu May 26, 2005 7:58 am Post subject: |
|
|
Did you try using the clause FETCH FIRST 2 ROWS ONLY in select statement. I guess it works. Try it out. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
nadh Intermediate
Joined: 08 Oct 2004 Posts: 192 Topics: 89
|
Posted: Fri May 27, 2005 3:31 am Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri May 27, 2005 7:21 am Post subject: |
|
|
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 |
|
 |
|
|