本文介绍了如何在“选择"菜单中添加偏移量在Oracle 11g中查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Oracle 11g中的选择"查询中添加偏移量.我只知道如何通过例如rownum <= 5添加限制这个问题不是重复的,我已经检查了其他问题,并且与我的问题无关.

How to add an offset in a "select" query in Oracle 11g.I only know how to add the limit by e.g rownum <= 5this question is not a duplicate, I already checked the other questions and are not related to mine.

那么,如何在Oracle 11g中添加偏移量?

So, how to add the offset in Oracle 11g ?

推荐答案

您可以通过指定OFFSET12c上轻松完成此操作.

You can do it easily on 12c by specifying OFFSET.

12c中,

SELECT val
FROM   table
ORDER BY val
OFFSET 4 ROWS FETCH NEXT 4 ROWS ONLY;

要在11g及更高版本上执行相同的操作,您需要两次使用ROWNUM,分别使用inner queryouter query.

To do the same on 11g and prior, you need to use ROWNUM twice, inner query and outer query respectively.

11g中的相同查询,

SELECT val
FROM   (SELECT val, rownum AS rnum
        FROM   (SELECT val
                FROM   table
                ORDER BY val)
        WHERE rownum <= 8)
WHERE  rnum > 4;

这里OFFSET是4.

这篇关于如何在“选择"菜单中添加偏移量在Oracle 11g中查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 01:13