/* ============================== using "page/size" */
select *
from (
select rownum as rn, a.*
from (
<your select>
) a
)
where rownum <= :size
and rn > (:page-1)*:size;
/* ============================== using "offset/limit" (one-based: offset=1,2,3...) */
select *
from (
select rownum as rn, a.*
from (
<your select>
) a
)
where rownum < :offset + :limit
and rn >= :offset;
/* ============================== using "offset/limit" (zero-based: offset=0,2,3...) */
select *
from (
select rownum as rn, a.*
from (
<your select>
) a
)
where rownum <= :offset + :limit
and rn > :offset;
Paging results in Oracle SQL.
2 Responses
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.