You can do it easily on 12c
by specifying OFFSET
.
In 12c
,
SELECT val
FROM table
ORDER BY val
OFFSET 4 ROWS FETCH NEXT 4 ROWS ONLY;
To do the same on 11g
and prior, you need to use ROWNUM
twice, inner query
and outer query
respectively.
The same query in 11g
,
SELECT val
FROM (SELECT val, rownum AS rnum
FROM (SELECT val
FROM table
ORDER BY val)
WHERE rownum <= 8)
WHERE rnum > 4;
Here OFFSET
is 4.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…