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
 

 

Row numbers in DB2

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

New User


Joined: 03 Nov 2006
Posts: 21

PostPosted: Wed Jul 23, 2008 6:40 pm    Post subject: Row numbers in DB2
Reply with quote

Hi All,

Am currently using DB2V7. I have to get the row numbers. Non of OLAP functions supports.Could you please somebody suggest or give sample query to fetch rows between 200 to 500.


Thanks for yours help!!
Back to top
View user's profile Send private message

dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 23, 2008 6:49 pm    Post subject:
Reply with quote

please, someone help!
I have the same problem.
don't know how to access row number 883.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Jul 23, 2008 7:21 pm    Post subject:
Reply with quote

Try this ... not sure whether this will work or not ... pls try and let us know ..

Code:


SELECT NAME, ROW# FROM SESSION.EMP TB1,
TABLE (SELECT COUNT(*)+1    AS ROW# FROM SESSION.EMP TB2 WHERE TB2.NAME < TB1.NAME) AS TEMP WHERE ROW# BETWEEN 200 AND 500;

Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10231
Location: italy

PostPosted: Wed Jul 23, 2008 7:30 pm    Post subject: Reply to: Row numbers in DB2
Reply with quote

what do rows from 200 to 500 have that makes them so interesting
and not those, let' s say, from 564 to 864 ?

in db2 the row number does not carry any intrinsic meaning..

if You unload and reload the table You might get different results
and that' s not a good application behavior,
processes should be repeatable and predictable
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jul 23, 2008 8:58 pm    Post subject:
Reply with quote

Hello,

Quote:
I have to get the row numbers. . .
query to fetch rows between 200 to 500
Of what use would these be? If you run the query 4 days in a row, you would most likely get 4 different sets of result rows.

If you better describe what you need to do, we may be able to offer better suggestions.

FWIW, in the database world, there is no nth row concept.

How is this related to OLAP?
Back to top
View user's profile Send private message
kumara.kranthi

New User


Joined: 03 Nov 2006
Posts: 21

PostPosted: Thu Jul 24, 2008 10:10 am    Post subject: Reply to: Row numbers in DB2
Reply with quote

Actually my requirement is to get the row numbers..so that i can display the in between rows on my jsp page..suppose i have 1000 rows.than i shold be able to display the rows in between 1 to 100 or 200 to 300 like that.Sorry i have not mentioed my requirement clearly.

For Example : If we are going to take Google , i the down we are getting page number like 1,2,3,4,5,6..etc,if we select 1 we get some rows say 1 to 25 again we select 2 we get 26 to 50.

Now i need DB2 query to fullfill this requirement.

Please Do the needfull.


Thanks,
Kranthi
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 24, 2008 10:56 am    Post subject:
Reply with quote

the row number is a value contained in a column???????
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 Incorrect output when trying to add n... monica1 PL/I & Assembler 10 Fri Jan 13, 2017 5:02 pm
No new posts Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm
No new posts comparing comp-3 and unpacked numbers juares castro COBOL Programming 3 Mon May 30, 2016 6:46 pm
No new posts Sort Trick for numbers pshongal DFSORT/ICETOOL 4 Tue Mar 22, 2016 1:33 pm
No new posts Display the exponential numbers in no... bipinpeter CLIST & REXX 4 Tue Jan 19, 2016 6:28 pm


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