Method-1: For database version Oracle12c or higher
SELECT fieldA, fieldB
FROM table
ORDER BY fieldA
OFFSET 5 ROWS FETCH NEXT 14 ROWS ONLY
Method-2: For database version Oracle11g or lower using analytical function RowNumber()
SELECT fieldA, fieldB
FROM (
SELECT fieldA, fieldB,
row_number() over (order by fieldA) rowRank
FROM table_name
)
WHERE rowRank BETWEEN 5 AND 14;
Method-3: For database version Oracle11g or lower using RowNum
SELECT T.* FROM (
SELECT T.*, rowNum as rowIndex
FROM (
SELECT fieldA, fieldB,
FROM table_name
)T)T
WHERE rowIndex > 0 AND rowIndex <= 20;
In some cases, I have found method-3 is faster than method-2 since order by clause is mandatory in method 2. However, if your database version is 12c or higher you must go for method-1.