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

Row numbers in DB2


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jul 23, 2008 7:30 pm
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

Moderator Emeritus


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

PostPosted: Wed Jul 23, 2008 8:58 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Generate random number from range of ... COBOL Programming 3
No new posts Feild level validation to test first ... JCL & VSAM 10
No new posts Line numbers contains last 6 digits o... TSO/ISPF 4
No new posts Random Numbers distributed evenly wit... COBOL Programming 6
Search our Forums:

Back to Top