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

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


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts Compare latest 2 rows of a table usin... DB2 1
Search our Forums:

Back to Top