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
 
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 Conditional highlighting of rows in I... packerm CLIST & REXX 2 Thu Sep 21, 2017 6:50 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 Convert rows and column into JSON for... Dinesh Manivannan DB2 2 Sun Sep 03, 2017 6:50 pm
No new posts compare 2 rows within the same file ram_vizag SYNCSORT 7 Wed Jun 14, 2017 12:34 am
No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm

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