oracle分页

oracle分页:

 

SELECT * FROM 
(
SELECT A.*, ROWNUM RN 
FROM (SELECT * FROM TABLE_NAME) A 
WHERE ROWNUM <= 40
)
WHERE RN >= 21

 

说明:

where rownum<=40,在实际应用中应是:where rownum<=page*pageSize

where rn >=21,在实际应用中应写成:where rn >= (page-1)*pageSize + 1

更为详细的可以参考:

http://yangtingkun.itpub.net/post/468/100278

你可能感兴趣的:(oracle)