:first-child { margin-top: 0; } blockquote > :last-child { margin-bottom: 0; } img { border: 0; max-width: 100%; height: auto !important; margin: 2px 0; } table { border-collapse: collapse; border: 1px solid #bbbbbb; } td, th { padding: 4px 8px; border-collapse: collapse; border: 1px solid #bbbbbb; } @media only screen and (-webkit-max-device-width: 1024px), only screen and (-o-max-device-width: 1024px), only screen and (max-device-width: 1024px), only screen and (-webkit-min-device-pixel-ratio: 3), only screen and (-o-min-device-pixel-ratio: 3), only screen and (min-device-pixel-ratio: 3) { html, body { font-size: 17px; } body { line-height: 1.7; padding: 0.75rem 0.9375rem; color: #353c47; } h1 { font-size: 2.125rem; } h2 { font-size: 1.875rem; } h3 { font-size: 1.625rem; } h4 { font-size: 1.375rem; } h5 { font-size: 1.125rem; } h6 { color: inherit; } ul, ol { padding-left: 2.5rem; } blockquote { padding: 0 0.9375rem; } }
-->

div{font-size:15px;}.wiz-table-tools .wiz-table-menu-item.active .wiz-table-menu-sub {display: block}.wiz-table-tools .wiz-table-menu-sub:before, .wiz-table-tools .wiz-table-menu-sub:after {position: absolute;content: " ";border-style: solid;border-color: transparent;border-bottom-color: #cccccc;left: 22px;margin-left: -14px;top: -8px;border-width: 0 8px 8px 8px;z-index:10;}.wiz-table-tools .wiz-table-menu-sub:after {border-bottom-color: #ffffff;top: -7px;}.wiz-table-tools .wiz-table-menu-sub-item {padding: 4px 12px;font-size: 14px;}.wiz-table-tools .wiz-table-menu-sub-item.split {border-top: 1px solid #E0E0E0;}.wiz-table-tools .wiz-table-menu-sub-item:hover {background-color: #ececec;}.wiz-table-tools .wiz-table-menu-sub-item.disabled {color: #bbbbbb;cursor: default;}.wiz-table-tools .wiz-table-menu-sub-item.disabled:hover {background-color: transparent;}.wiz-table-tools .wiz-table-menu-item.wiz-table-cell-bg:hover .wiz-table-color-pad {display: block;}.wiz-table-tools .wiz-table-color-pad {display: none;padding: 10px;box-sizing: border-box;width: 85px;height: 88px;background-color: #fff;cursor: default;}.wiz-table-tools .wiz-table-color-pad > div{font-size:15px;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item {display: inline-block;width: 15px;height: 15px;margin-right: 9px;position: relative;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item i.pad-demo {position: absolute;top:3px;left:0;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item .icon-oblique_line{color: #cc0000;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item:last-child {margin-right: 0;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item.active i.editor-icon.icon-box {color: #448aff;}.wiz-table-tools .wiz-table-cell-align {display: none;padding: 10px;box-sizing: border-box;width: 85px;height: 65px;background-color: #fff;cursor: default;}.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item {display: inline-block;width: 15px;height: 15px;margin-right: 9px;position: relative;}.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item:last-child {margin-right:0}.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item i.valign{position: absolute;top:3px;left:0;color: #d2d2d2;}.wiz-table-tools .wiz-table-cell-align-item.active i.editor-icon.valign {color: #a1c4ff;}.wiz-table-tools .wiz-table-cell-align-item.active i.editor-icon.icon-box,.wiz-table-tools .wiz-table-cell-align-item.active i.editor-icon.align {color: #448aff;}.wiz-table-tools .wiz-table-color-pad .wiz-table-color-pad-item:last-child,.wiz-table-tools .wiz-table-cell-align .wiz-table-cell-align-item:last-child {margin-right: 0;}th.wiz-selected-cell-multi, td.wiz-selected-cell-multi {background: rgba(0,102,255,.05);}th:before,td:before,#wiz-table-col-line:before,#wiz-table-range-border_start_right:before,#wiz-table-range-border_range_right:before{content: " ";position: absolute;top: 0;bottom: 0;right: -5px;width: 9px;cursor: col-resize;background: transparent;z-index:100;}th:after,td:after,#wiz-table-row-line:before,#wiz-table-range-border_start_bottom:before,#wiz-table-range-border_range_bottom:before{content: " ";position: absolute;left: 0;right: 0;bottom: -5px;height: 9px;cursor: row-resize;background: transparent;z-index:100;}.wiz-table-container {}.wiz-table-body {position:relative;padding:0 0 10px;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;}.wiz-table-body table {margin:0;outline:none;}td,th {height:28px;word-break:break-all;box-sizing:border-box;outline:none;}body pre.prettyprint {padding:0;}body pre.prettyprint code {white-space: pre;}body pre.prettyprint.linenums {box-shadow:none; overflow: auto;-webkit-overflow-scrolling: touch;}body pre.prettyprint.linenums ol.linenums {box-shadow: 40px 0 0 #FBFBFC inset, 41px 0 0 #ECECF0 inset; padding: 10px 10px 10px 40px !important;}
-->

over() 函数功能:

分析函数是 Oracle 专门用于解决复杂报表统计需求的功能强大的函数,它可以在数据中进行分组然后计算基于组的某种统计值,并且每一组的每一行都可以返回一个统计值。
 
分析函数和聚合函数的区别:
普通的聚合函数用 group by 分组,每个分组返回一个统计值,而分析函数采用 partition by 分组,并且每组每行都可以返回一个统计值。
 
over() 函数语法:
over() 分析函数经常与分组排序窗口三种子句结合使用。同时,over() 分析函数还经常与 sum()、rank()、min() 等函数结合使用。
注意:分组、排序、窗口三种子句可自由结合
1.分组
分组语句格式为 over(partition by partition_col)
通过分组子句,将可以基于每条记录中对应的分区字段,对数据进行分组。随后基于分组,结合 sum()、rank()、min() 等函数进行运算。
例如:查找对每个员工的工资,并显示其所在部门的最高工资。
SQL> SELECT userid, salary, deptid, sum(salary) over(partition by deptid)
FROM salary;
2.排序
分组语句格式为 over(order by order_col)
通过排序子句,将可以基于每条记录中对应的排序字段,做以排序字段值为边界的排序(每条记录的排序可能不同)。随后基于排序,结合 sum()、rank()、min() 等函数进行运算。
例如:查找对每个员工的工资,并显示不高于其工资的总工资和。
SQL> SELECT userid, salary, deptid, sum(salary) over(order by salary asc)
FROM salary;

例如:查找对每个员工的工资,并显示不低于其工资的总工资和。
SQL> SELECT userid, salary, deptid, sum(salary) over(order by salary desc)
FROM salary;
3.窗口

分组语句格式为 over(order by order_col [rows | range] between xxx preceding and yyy following)
首先通过排序子句,将可以基于每条记录中对应的排序字段,做以排序字段值为中心,xxx 值为向前范围,yyy 为向后范围的排序(每条记录的排序可能不同)。随后基于排序,结合 sum()、rank()、min() 等函数进行运算。
注意:建设排序字段值为 a,则窗口的大小为 (a - xxx) <= range <= (a + yyy)。
例如:查找对每个员工的工资,并显示按工资排序,工资比他低的前两位员工与其自身的工资和。
SQL> SELECT userid, salary, deptid, sum(salary) over(partition by deptid order by salary rows BETWEEN 2 preceding AND 0 following)
FROM salary;
 
例如:查找对每个员工的工资,并显示比他工资少 800 元以内(含 800 元),且不高于他工资的工资和。
SQL> SELECT userid, salary, deptid, sum(salary) over(partition by deptid order by salary range BETWEEN 800 preceding AND 0 following)
FROM salary;
 
 
 
 

Oracle 中 over() 函数的更多相关文章

  1. Oracle 中 decode 函数用法

    Oracle 中 decode 函数用法 含义解释:decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值) 该函数的含义如下:IF 条件=值1 THEN RETURN(翻译 ...

  2. Oracle中wm_concat()函数的使用

    Oracle中wm_concat()函数的使用 wm_concat()函数是oracle行列转换函数,该函数可以把列值以‘,’分割开来,并显示成一行. 1.原数据: 2.把结果分组以‘|’分隔,以一行 ...

  3. Oracle中trunc函数、round 函数、ceil函数和floor函数的使用

    Oracle中trunc函数.round 函数.ceil函数和floor函数的使用 1.1trunc函数处理数字 trunc函数返回处理后的数值,其工作机制与ROUND函数极为类似,只是该函数不对指定 ...

  4. Oracle中REGEXP_SUBSTR函数(转)

    Oracle中REGEXP_SUBSTR函数 Oracle中REGEXP_SUBSTR函数的使用说明: 题目如下:在oracle中,使用一条语句实现将'17,20,23'拆分成'17','20','2 ...

  5. Oracle中sign函数和decode函数的使用

    Oracle中sign函数和decode函数的使用 1.比较大小函数SIGN sign(x)或者Sign(x)叫做 符号函数,其功能是取某个数的符号(正或负): 当x>0,sign(x)=1; ...

  6. oracle中extract()函数----用于截取年、月、日、时、分、秒

    oracle中extract()函数从oracle 9i中引入,用于从一个date或者interval类型中截取到特定的部分 语法如下: extract ( { year | month | day ...

  7. oracle中使用函数控制过程是否执行(结合job使用)

    oracle中使用函数控制过程是否执行(结合job使用时候,循环时间不好写的时候,可以此种方法比较方便) CREATE OR REPLACE FUNCTION wsbs_pk_date_validat ...

  8. Oracle中SYS_CONNECT_BY_PATH函数的妙用 ;

    Oracle 中SYS_CONNECT_BY_PATH函数是非常重要的函数,下面就为您介绍一个使用SYS_CONNECT_BY_PATH函数的例子,实例如下: 数据准备: ),b )); ', 'A' ...

  9. oracle中floor函数和to_number函数区别

     oracle中floor函数没有值默认是0,number函数没有值默认是空 

  10. Oracle中REGEXP_SUBSTR函数(字符串转多行)

    Oracle中REGEXP_SUBSTR函数 Oracle中REGEXP_SUBSTR函数的使用说明: 题目如下: 在oracle中,使用一条语句实现将'17,20,23'拆分成'17','20',' ...

随机推荐

  1. Leetcode 1015. Smallest Integer Divisible by K

    思路显然是暴力枚举. 但是两个问题: 1.当1的位数非常大时,模运算很费时间,会超时. 其实每次不用完全用'11111...'来%K,上一次的余数*10+1后再%K就行. 证明: 令f(n)=1111 ...

  2. Asphyre Sphinx is a cross-platform framework for developing 2D/3D video games and interactive business applications

    Introduction Introduction Asphyre Sphinx is a cross-platform framework for developing 2D/3D video ga ...

  3. VS2017 Product Key

    Enterprise: NJVYC-BMHX2-G77MM-4XJMR-6Q8QF Professional: KBJFW-NXHK6-W4WJM-CRMQB-G3CDH

  4. 接口测试基础——第2篇smtplib发送带附件的邮件

    我先给大家补充一个用QQ发送纯文本电子邮件的代码,用QQ的朋友可以参考一下: # coding=utf-8 import smtplib from email.mime.text import MIM ...

  5. JavaScript 冒号(:)详解

    1.switch语句分支 2.?:三元表达式的false 3.声明对象直接量的成员 4.声明标签 1和2相信地球人都知道吧?如果有人不知道,那我改成地球上的程序员都知道,哈哈 3.对象直接量我们也经常 ...

  6. miniofs 配置使用

    1. rpm  // RPM 包下载 https://github.com/minio/minfs/releases/tag/RELEASE.2017-02-26T20-20-56Z // 安装 yu ...

  7. linux 查看系统信息和安装哪些软件的命令

    https://www.cnblogs.com/wangkongming/p/4531341.html 查看系统磁盘硬盘占用率 https://blog.csdn.net/aaashen/articl ...

  8. maven help:system

    lifecycle:http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html bindings:ht ...

  9. further occurrences of HTTP header parsing errors will be logged at DEBUG level.

    1.   获取参数Json的值为null String json=request.getParameter("Json"); 首先检查是否有下面的东东, 信息: Error par ...

  10. .Net上传文件超过了最大请求长度

    错误消息:超过了最大请求长度    错误原因:asp.net默认最大上传文件大小为4M,运行超时时间为90S. 修改web.config文件可以改变这个默认值为 <configuration&g ...