Offset and Fetch clauses are used in conjunction with Select and order by clause to provide a means to retrieve a range of records.
Offset: the offset argument is used to identify the starting point to retirn rows from a result set.
Fetch: It is used to return a set of number of rows.
Syntax:
Select column_name(s)
From table_name
Order by column_name
Offset rows_to_skip ROWS
Fetch Next number_of_rows ROWS ONLY;
Example:
Suppose you have 9 rows in a db table and you want to fetch 3rd to 7th one
Select orderNumber,Customer
From orders
Order by orderNumber
Offset 2 ROWS
Fetch Next 5 Rows ONLY;
No comments:
Post a Comment