How to use ROW_NUMBER () in a where clause in a DB2 database. I tried below, but this did not work:
SELECT * FROM CSPAPP.LOCATIONS WHERE (ROW_NUMBER() OVER(ORDER BY LOCATION)) BETWEEN 100 AND 200
This gave an error: misuse of aggregate function or OLAP function.
I also tried using the following methods:
SELECT (ROW_NUMBER() OVER(ORDER BY LOCATION)) AS RN ,* FROM CSPAPP.LOCATIONS WHERE RN < 200 SELECT (ROW_NUMBER() OVER(ORDER BY LOCATION)) AS RN ,LOCATION FROM CSPAPP.LOCATIONS WHERE RN < 200
source share