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
Related Q&A from Kent Milligan
Create a host variable of the where in statement on the fly with dynamic SQL. Continue Reading
To solve the SQL error -321 on IBM i6.1, use the new values statement to overcome the error. If you are using an older release, declare a cursor ... Continue Reading
When working with DB2 files with columns that have both short and long names, there is no option choose which column names are returned via ODBC ... Continue Reading