Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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 Data replication from multiple Db2 ta... kishpra DB2 5 Mon Mar 27, 2017 9:58 pm
No new posts Unable to catalog a gdg dataset resid... Shovan JCL & VSAM 7 Fri Mar 24, 2017 2:24 pm
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Calling procedure with multiple entri... steve-myers PL/I & Assembler 5 Fri Jan 27, 2017 3:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us