Updated on 2022-11-18 GMT+08:00

OFFSET

OFFSET

OFFSET is used to discard the first several rows of data in the result set.

OFFSET count [ ROW | ROWS ]

If ORDER BY exists, OFFSET applies to the sorted result set. OFFSET discards the first several rows of data and retains the sorted data set.

SELECT name FROM fruit ORDER BY name OFFSET 3;
name
------------
peach
pear
watermelon
(3 rows)

Otherwise, if ORDER BY is not used, the discarded row may be any row. If the number of rows specified by OFFSET is greater than or equal to the size of the result set, the returned result is null.