<bdo id='vIAnX'></bdo><ul id='vIAnX'></ul>
      <legend id='vIAnX'><style id='vIAnX'><dir id='vIAnX'><q id='vIAnX'></q></dir></style></legend>

      <small id='vIAnX'></small><noframes id='vIAnX'>

    1. <i id='vIAnX'><tr id='vIAnX'><dt id='vIAnX'><q id='vIAnX'><span id='vIAnX'><b id='vIAnX'><form id='vIAnX'><ins id='vIAnX'></ins><ul id='vIAnX'></ul><sub id='vIAnX'></sub></form><legend id='vIAnX'></legend><bdo id='vIAnX'><pre id='vIAnX'><center id='vIAnX'></center></pre></bdo></b><th id='vIAnX'></th></span></q></dt></tr></i><div id='vIAnX'><tfoot id='vIAnX'></tfoot><dl id='vIAnX'><fieldset id='vIAnX'></fieldset></dl></div>
    2. <tfoot id='vIAnX'></tfoot>

      SQL (ORACLE):ORDER BY 和 LIMIT

      时间:2023-09-19

          <tbody id='GqndR'></tbody>
      • <i id='GqndR'><tr id='GqndR'><dt id='GqndR'><q id='GqndR'><span id='GqndR'><b id='GqndR'><form id='GqndR'><ins id='GqndR'></ins><ul id='GqndR'></ul><sub id='GqndR'></sub></form><legend id='GqndR'></legend><bdo id='GqndR'><pre id='GqndR'><center id='GqndR'></center></pre></bdo></b><th id='GqndR'></th></span></q></dt></tr></i><div id='GqndR'><tfoot id='GqndR'></tfoot><dl id='GqndR'><fieldset id='GqndR'></fieldset></dl></div>

        <tfoot id='GqndR'></tfoot>
          <legend id='GqndR'><style id='GqndR'><dir id='GqndR'><q id='GqndR'></q></dir></style></legend>
          • <small id='GqndR'></small><noframes id='GqndR'>

              • <bdo id='GqndR'></bdo><ul id='GqndR'></ul>

                本文介绍了SQL (ORACLE):ORDER BY 和 LIMIT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我想按属性对我的数据库中的所有数据进行排序,并且仅在使用 LIMIT 和 OFFSET 之后进行排序.

                I want do sorting by property ALL data in my db and ONLY AFTER that use LIMIT and OFFSET.

                这样的查询:

                SELECT select_list
                    FROM table_expression
                    [ ORDER BY ... ]
                    [ LIMIT { number | ALL } ] [ OFFSET number ] 
                

                一旦找到排序结果的第一个 row_count 行,我就知道排序结束.我可以在调用 LIMIT 和 OFFSET 之前对所有数据进行排序吗?

                I know the sorting ends as soon as it has found the first row_count rows of the sorted result. Can I do sorting all data before calling LIMIT and OFFSET?

                推荐答案

                在 12.1 之前,Oracle 不支持 LIMITOFFSET 关键字.如果要检索结果集的第 N 到 M 行,则需要类似以下内容:

                Prior to 12.1, Oracle does not support the LIMIT or OFFSET keywords. If you want to retrieve rows N through M of a result set, you'd need something like:

                SELECT a.*
                  FROM (SELECT b.*,
                               rownum b_rownum
                          FROM (SELECT c.*
                                  FROM some_table c
                                 ORDER BY some_column) b
                         WHERE rownum <= <<upper limit>>) a
                 WHERE b_rownum >= <<lower limit>>
                

                或使用解析函数:

                SELECT a.*
                  FROM (SELECT b.*,
                               rank() over (order by some_column) rnk
                          FROM some_table)
                 WHERE rnk BETWEEN <<lower limit>> AND <<upper limit>>
                 ORDER BY some_column
                

                这两种方法中的任何一种都会为您提供排序结果的第 N 到 M 行.

                Either of these approaches will sort give you rows N through M of the sorted result.

                在 12.1 及更高版本中,您可以使用 OFFSET 和/或 FETCH [FIRST |NEXT] 运算符:

                In 12.1 and later, you can use the OFFSET and/or FETCH [FIRST | NEXT] operators:

                SELECT *
                  FROM some_table
                 ORDER BY some_column
                 OFFSET <<lower limit>> ROWS
                  FETCH NEXT <<page size>> ROWS ONLY
                

                这篇关于SQL (ORACLE):ORDER BY 和 LIMIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:我们可以在 PL/SQL 中使用线程吗? 下一篇:Oracle 的自动增量

                相关文章

                  • <bdo id='ORplP'></bdo><ul id='ORplP'></ul>

                  <small id='ORplP'></small><noframes id='ORplP'>

                1. <i id='ORplP'><tr id='ORplP'><dt id='ORplP'><q id='ORplP'><span id='ORplP'><b id='ORplP'><form id='ORplP'><ins id='ORplP'></ins><ul id='ORplP'></ul><sub id='ORplP'></sub></form><legend id='ORplP'></legend><bdo id='ORplP'><pre id='ORplP'><center id='ORplP'></center></pre></bdo></b><th id='ORplP'></th></span></q></dt></tr></i><div id='ORplP'><tfoot id='ORplP'></tfoot><dl id='ORplP'><fieldset id='ORplP'></fieldset></dl></div>

                  1. <legend id='ORplP'><style id='ORplP'><dir id='ORplP'><q id='ORplP'></q></dir></style></legend>
                  2. <tfoot id='ORplP'></tfoot>