What is Page results

An extension to the ORDER BY clause called OFFSET-FETCH enables you to return only a range of the rows selected by your query. It adds the ability to supply a starting point (an offset) and a value to specify how many rows you would like to return (a fetch value). This extension provides a convenient technique for paging through results.

If you want to return rows a “page” at a time (using whatever number you choose for a page), you’ll need to consider that each query with an OFFSET-FETCH clause runs independently of any other queries. There’s no server-side state maintained, and you’ll need to track your position through a result set via client-side code.

OFFSET-FETCH syntax

The syntax for the OFFSET-FETCH clause, which is technically part of the ORDER BY clause, is as follows:

SQLCopy

OFFSET { integer_constant | offset_row_count_expression } { ROW | ROWS }
[FETCH { FIRST | NEXT } {integer_constant | fetch_row_count_expression } { ROW | ROWS } ONLY]

Leave a Reply

Your email address will not be published. Required fields are marked *