SELECT * FROMtable
(tab
SELECT ROW_NUMBER() OVER(ORDER BY id) AS rownum, * FROM tablenameab
) AS a WHERE
a.rownum > ((pagenum - 1) * pagesize) AND a.rownum <= (pagenum * pagesize)