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
 

 

How one can retrieve rows from 20 to 30 from 100 Rows

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
bsng_surru

New User


Joined: 07 Mar 2005
Posts: 16

PostPosted: Sat Mar 26, 2005 11:29 pm    Post subject: How one can retrieve rows from 20 to 30 from 100 Rows
Reply with quote

suppose there are 100 rows in a table how one can retrieve rows from 20 to 30?
Back to top
View user's profile Send private message

gorle_n4

New User


Joined: 11 Mar 2005
Posts: 8
Location: hyderabad

PostPosted: Mon Mar 28, 2005 11:42 am    Post subject: suppose there are 100 rows in a table how one can retrieve r
Reply with quote

hi!
u can do it by using rowid. iam not sure. plz try it.
all the best.
Back to top
View user's profile Send private message
sangar_blr

New User


Joined: 01 Apr 2005
Posts: 8

PostPosted: Fri Apr 01, 2005 2:36 pm    Post subject:
Reply with quote

Hi ,
u can find the row id of the first row then u use in between cluase in ur quary. It may be work!!! im not sure..
Back to top
View user's profile Send private message
sangar_blr

New User


Joined: 01 Apr 2005
Posts: 8

PostPosted: Fri Apr 01, 2005 2:38 pm    Post subject:
Reply with quote

Hi ,
u will find the row id of the first row then u use in between cluase in ur quary. It may be work!!! im not sure..
Back to top
View user's profile Send private message
Girishm

New User


Joined: 09 Mar 2005
Posts: 35
Location: Mysore

PostPosted: Fri Apr 01, 2005 5:50 pm    Post subject: Re: select rows randomly
Reply with quote

Hi Surendranath Gupta,

The below query will fulfill your need to select rows randomly.

WITH TEMPTABLE AS
(SELECT COL_NAME1, COL_NAME2, ROW_NUMBER() OVER (ORDER BY COL_NAME1)
AS RN FROM YOUR_TABLE_NAME )
SELECT COL_NAME1, COL_NAME2, RN
FROM TEMPTABLE WHERE RN BETWEEN 20 AND 30 ORDER BY RN

PS: In the order by clause (col_name1) better you use PRMARY KEY.

___________
GM
Back to top
View user's profile Send private message
bsng_surru

New User


Joined: 07 Mar 2005
Posts: 16

PostPosted: Thu Apr 07, 2005 10:33 pm    Post subject:
Reply with quote

grishm thanks
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 DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts Need to retrieve Julian_date Suganya87 DB2 4 Wed Aug 17, 2016 7:27 pm
No new posts Can we use OPTIMIZE FOR 1 ROWS for fe... cvijay784 DB2 1 Fri Aug 05, 2016 11:56 am


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