Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

implementing paging logic in DB2 SQL

Is there a way to implement paging logic in DB2 SQL, where records can be fetched page wise. The following query works only for queries with no joins. When queries with join are used the ROW_NUM is returned as 0 and paging cannot be done.

SELECT * FROM (SELECT ROWNUMBER() OVER() AS ROW_NUM, Results.*
                         FROM (SELECT * FROM Table1 ) AS Results) AS PagedResults
WHERE PagedResults.ROW_NUM>0 AND PagedResults.ROW_NUM<=10

Thanks in advance

like image 933
TrustyCoder Avatar asked Oct 15 '22 01:10

TrustyCoder


1 Answers

How to query range of data in DB2 with highest performance?

like image 53
Fuangwith S. Avatar answered Oct 19 '22 01:10

Fuangwith S.