Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
selcting multiple rows

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: selcting multiple rows
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    Post subject: Re: selcting multiple rows
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    Post subject: Re: selcting multiple rows
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    Post subject: may be you can try this
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Conditional highlighting of rows in I... packerm CLIST & REXX 2 Thu Sep 21, 2017 6:50 pm
No new posts ejck thru rexx to multiple jobs insid... Susanta All Other Mainframe Topics 5 Tue Sep 19, 2017 1:39 pm
No new posts column with count of rows within dist... ronald wouterson DB2 4 Sun Sep 17, 2017 9:48 pm
No new posts PLI - printing from multiple programs Pedro PL/I & Assembler 8 Fri Sep 08, 2017 6:36 am
No new posts Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us