Q
Problem solve Get help with specific problems with your technologies, process and projects.

Access a RowNumber function in a SQL query

Is there a way to access a RowNumber in a SQL query? Something like this:

 SELECT T1.c1, T2.c2 FROM T1,
 (SELECT c2 FROM
   (SELECT c2, ROWNUMBER() OVER(ORDER BY c3) AS rn FROM T2) AS T2
  WHERE rn <= 10) AS T2; 

We can't get this to work. We are running V5R2 DB2 level 6 with PTF's from Feb. 25, 2003.


The RowNumber function is not yet supported by DB2 UDB for iSeries. About the closest function to this on the iSeries would be the RRN() scalar function. Another alternative is writing your own user-defined function.

==================================
MORE INFORMATION ON THIS TOPIC
==================================

Search400.com's targeted search engine: Get relevant information on DB2/400.

The Best Web Links: tips, tutorials and more.

Check out this online event, Getting the Most out of SQL & DB2 UDB for the iSeries.


Dig Deeper on Oracle on iSeries

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close