OFFSET, FETCH
Retrieves a slice of rows from an ordered set
SELECT <columns> FROM ...
[WHERE ...]
[ORDER BY ...]
[OFFSET <offset-fetch-expression> { ROW | ROWS }]
[FETCH { FIRST | NEXT }
[<offset-fetch-expression>] { ROW | ROWS } ONLY]
<offset-fetch-expression> ::=
<integer-literal>
| <query-parameter>
| Argument | Description |
|---|---|
integer-literal |
Integer literal |
query-parameter |
Query parameter place-holder. |
The OFFSET and FETCH clauses are an SQL standard-compliant equivalent for FIRST/SKIP, and an alternative for ROWS.The OFFSET clause specifies the number of rows to skip.The FETCH clause specifies the number of rows to fetch.
When <offset-fetch-expression> is left out of the FETCH clause (e.g. FETCH FIRST ROW ONLY), one row will be fetched.
The choice between ROW or ROWS, or FIRST or NEXT in the clauses is just for aesthetic purposes (e.g. making the query more readable or grammatically correct).There is no difference between OFFSET 10 ROW or OFFSET 10 ROWS, or FETCH NEXT 10 ROWS ONLY or FETCH FIRST 10 ROWS ONLY.
As with SKIP and FIRST, OFFSET and FETCH clauses can be applied independently, in both top-level and nested query expressions.
|
Note
|
|