IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

selcting multiple rows


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
cr_aranganathan

New User


Joined: 26 Sep 2005
Posts: 3

PostPosted: Wed Sep 28, 2005 7:08 pm
Reply with quote

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
View user's profile Send private message
mvanandkumar

New User


Joined: 01 Sep 2005
Posts: 11

PostPosted: Thu Sep 29, 2005 3:29 pm
Reply with quote

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. icon_wink.gif
Back to top
View user's profile Send private message
karthi_ind

Active User


Joined: 24 Feb 2004
Posts: 131
Location: Chennai

PostPosted: Thu Sep 29, 2005 3:53 pm
Reply with quote

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
View user's profile Send private message
tdsvamsidhar

New User


Joined: 03 Oct 2005
Posts: 7

PostPosted: Mon Oct 03, 2005 1:25 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
Search our Forums:

Back to Top