Thursday, April 21, 2022

DB Offset - Fetch clause

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

Featured Post

11g to 12c OSB projects migration points

1. Export 11g OSB code and import in 12c Jdeveloper. Steps to import OSB project in Jdeveloper:   File⇾Import⇾Service Bus Resources⇾ Se...