View previous topic :: View next topic
|
Author |
Message |
cr_aranganathan
New User
Joined: 26 Sep 2005 Posts: 3
|
|
|
|
how to select multiple rows using select statement without using any condition.That if table contains 10 rows i want to select first or last n number rows without giving any condition in select statement. |
|
Back to top |
|
|
mvanandkumar
New User
Joined: 01 Sep 2005 Posts: 11
|
|
|
|
For DB2 version 7 / 8 not sure...the latest version has an SQL parm
'FETCH FIRST nnnn ROWS' will get you first nnnn rows....
There is no way you can get LAST nnn rows without doing some programming / including condition. |
|
Back to top |
|
|
karthi_ind
Active User
Joined: 24 Feb 2004 Posts: 131 Location: Chennai
|
|
|
|
hi,
Ur question is not clear,
you can give
SELECT * FROM <tablename> FETCH FIRST 10 ROWS ONLY;
This option vll work only if ur db2 version is 7.1 and higher.
Corrections are welcome...
Karthi G. |
|
Back to top |
|
|
tdsvamsidhar
New User
Joined: 03 Oct 2005 Posts: 7
|
|
|
|
I think you can use order by clause for getting the first/last 10 rows using the same mentioned by others//
SELECT DEAL FROM LOG
ORDER BY DEAL ASC
FETCH FIRST 10 ROWS ONLY ;
SELECT DEAL FROM LOG
ORDER BY DEAL DESC
FETCH FIRST 10 ROWS ONLY ;
Please correct me if I am wrong in suggesting this solution. |
|
Back to top |
|
|
|