<legend id='1J2cz'><style id='1J2cz'><dir id='1J2cz'><q id='1J2cz'></q></dir></style></legend>

    <small id='1J2cz'></small><noframes id='1J2cz'>

        <bdo id='1J2cz'></bdo><ul id='1J2cz'></ul>

        <i id='1J2cz'><tr id='1J2cz'><dt id='1J2cz'><q id='1J2cz'><span id='1J2cz'><b id='1J2cz'><form id='1J2cz'><ins id='1J2cz'></ins><ul id='1J2cz'></ul><sub id='1J2cz'></sub></form><legend id='1J2cz'></legend><bdo id='1J2cz'><pre id='1J2cz'><center id='1J2cz'></center></pre></bdo></b><th id='1J2cz'></th></span></q></dt></tr></i><div id='1J2cz'><tfoot id='1J2cz'></tfoot><dl id='1J2cz'><fieldset id='1J2cz'></fieldset></dl></div>
        <tfoot id='1J2cz'></tfoot>
      1. Oracle 中的 OVER 子句

        时间:2023-09-18

      2. <legend id='aPbXZ'><style id='aPbXZ'><dir id='aPbXZ'><q id='aPbXZ'></q></dir></style></legend>

        • <bdo id='aPbXZ'></bdo><ul id='aPbXZ'></ul>
          <tfoot id='aPbXZ'></tfoot>

                <tbody id='aPbXZ'></tbody>

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

                1. 本文介绍了Oracle 中的 OVER 子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Oracle 中的OVER 子句是什么意思?

                  What is the meaning of the OVER clause in Oracle?

                  推荐答案

                  OVER 子句指定了分区、排序和窗口over which"解析函数运行.

                  The OVER clause specifies the partitioning, ordering and window "over which" the analytic function operates.

                  示例 1:计算移动平均线

                  AVG(amt) OVER (ORDER BY date ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING)
                  
                  date   amt   avg_amt
                  =====  ====  =======
                  1-Jan  10.0  10.5
                  2-Jan  11.0  17.0
                  3-Jan  30.0  17.0
                  4-Jan  10.0  18.0
                  5-Jan  14.0  12.0
                  

                  它在按日期排序的行上的移动窗口(3 行宽)上运行.

                  It operates over a moving window (3 rows wide) over the rows, ordered by date.

                  示例 2:计算运行余额

                  SUM(amt) OVER (ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
                  
                  date   amt   sum_amt
                  =====  ====  =======
                  1-Jan  10.0  10.0
                  2-Jan  11.0  21.0
                  3-Jan  30.0  51.0
                  4-Jan  10.0  61.0
                  5-Jan  14.0  75.0
                  

                  它在一个包含当前行和所有先前行的窗口上运行.

                  It operates over a window that includes the current row and all prior rows.

                  注意:对于带有 OVER 子句指定排序 ORDER 的聚合,默认窗口是 UNBOUNDED PRECEDINGCURRENT ROW,所以上面的表达式可以简化为,结果相同:

                  Note: for an aggregate with an OVER clause specifying a sort ORDER, the default window is UNBOUNDED PRECEDING to CURRENT ROW, so the above expression may be simplified to, with the same result:

                  SUM(amt) OVER (ORDER BY date)
                  

                  示例 3:计算每个组内的最大值

                  MAX(amt) OVER (PARTITION BY dept)
                  
                  dept  amt   max_amt
                  ====  ====  =======
                  ACCT   5.0   7.0
                  ACCT   7.0   7.0
                  ACCT   6.0   7.0
                  MRKT  10.0  11.0
                  MRKT  11.0  11.0
                  SLES   2.0   2.0
                  

                  它在一个包含特定部门的所有行的窗口上运行.

                  It operates over a window that includes all rows for a particular dept.

                  SQL Fiddle:http://sqlfiddle.com/#!4/9eecb7d/122

                  SQL Fiddle: http://sqlfiddle.com/#!4/9eecb7d/122

                  这篇关于Oracle 中的 OVER 子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:从查询结果中选择随机结果样本 下一篇:Oracle 中的视图是什么?

                  相关文章

                  <tfoot id='DCkNh'></tfoot>

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

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