)*20=18

percentile_disc()

PERCENTILE_DISC

这里就不做详细分析。

Syntax

Purpose

PERCENTILE_DISC is an inverse distribution function that assumes a discrete distribution model. It takes a percentile value and a sort specification and returns an element from the set. Nulls are ignored in the calculation.

This function takes as an argument any numeric data type or any nonnumeric data type that can be implicitly converted to a numeric data type. The function returns the same data type as the numeric data type of the argument.

The first expr must evaluate to a numeric value between 0 and 1, because it is a percentile value. This expression must be constant within each aggregate group. The ORDER BY clause takes a single expression that can be of any type that can be sorted.

For a given percentile value P, PERCENTILE_DISC sorts the values of the expression in the ORDER BY clause and returns the value with the smallest CUME_DIST value (with respect to the same sort specification) that is greater than or equal to P.

Aggregate Example

See aggregate example for .

Analytic Example

The following example calculates the median discrete percentile of the salary of each employee in the sample table hr.employees:

SELECT last_name, salary, department_id,

PERCENTILE_DISC(0.5) WITHIN GROUP (ORDER BY salary DESC)

OVER (PARTITION BY department_id) "Percentile_Disc",

CUME_DIST() OVER (PARTITION BY department_id

ORDER BY salary DESC) "Cume_Dist"

FROM employees

WHERE department_id in (30, 60)

ORDER BY last_name, salary, department_id;

LAST_NAME SALARY DEPARTMENT_ID Percentile_Disc Cume_Dist

------------------------- ---------- ------------- --------------- ----------

Austin 4800 60 4800 .8

Baida 2900 30 2900 .5

Colmenares 2500 30 2900 1

Ernst 6000 60 4800 .4

Himuro 2600 30 2900 .833333333

Hunold 9000 60 4800 .2

Khoo 3100 30 2900 .333333333

Lorentz 4200 60 4800 1

Pataballa 4800 60 4800 .8

Raphaely 11000 30 2900 .166666667

Tobias 2800 30 2900 .666666667

The median value for Department 30 is 2900, which is the value whose corresponding percentile (Cume_Dist) is the smallest value greater than or equal to 0.5. The median value for Department 60 is 4800, which is the value whose corresponding percentile is the smallest value greater than or equal to 0.5.

percentile_disc:percentile_disc函数在功能上类似于percentile_cont函数,只是percentile_cont函数使用了连续分布模型,而percentile_disc函数使用了离期 分布模型。当没有值与指定的percent_rank精确匹配的时候,percentile_cont(0.5)会计算两个离得最近的值的平均值。相反,在升序排列的情况下,percentile_disc函数只取比所传递的参数percent_rank值更大的值。在降序排列的时候,percentile_disc函数只取比所传递的参数percent_rank值更小的值。

oracle 百分位数,oracle分析函数 percent_rank, percentile_cont, percentile_disc相关推荐

  1. oracle 百分位数,Oracle分析函数PERCENTILE_CONT

    查询各部门中薪水分布处于25%.50%.75%位置的人的薪水,percent_rank()是确定排行中的相对位置. 查询各部门中薪水分布处于25%.50%.75%位置的人的薪水,percent_ran ...

  2. oracle 排序的分析函数,Oracle分析函数用法详解

    OVER(PARTITION BY)开窗函数用法 开窗函数,Oracle从8.1.6开始提供开窗函数,开窗函数用于计算基于组的某种聚合值,它和聚合函数的不同之处是: 对于每个组返回多行,而聚合函数对于 ...

  3. oracle中over()分析函数的用法

    摘自: http://www.poluoluo.com/jzxy/201004/81921.html 百度文库也记载了oracle中over()分析函数的用法 在泡坛子的时候中无意中发现了这个函数,才 ...

  4. 利用Oracle内置分析函数进行高效统计汇总

    利用Oracle内置分析函数进行高效统计汇总 分析函数是Oracle从8.1.6开始引入的一个新的概念,为我们分析数据提供了一种简单高效的处理方式.在分析函数出现以前,我们必须使用自联查询,子查询或者 ...

  5. Oracle转MySQL存储函数percentile_cont(比例) WITHIN GROUP( ORDER BY to_number(分数) )用法

    在Oracle中会用到 percentile_cont(比例) WITHIN GROUP( ORDER BY to_number(分数) ) 的写法,但在MySQL中却没有percentile_con ...

  6. oracle取最小值怎么写,【Oracle】oracle取最大值和最小值的几个方法汇总

    (1)oracle使用keep分析函数取最值记录 --取工资sal最大的雇员姓名及其工资,以及工资sal最少的雇员姓名及其工资 selectdeptno, empno, ename, sal,max( ...

  7. Linux下docker安装配置oracle,oracle创建用户并远程连接,实测可用!

    最近在给同学弄毕业设计的数据库,因为oracle在个人电脑上极不稳定,所以他的电脑数据库崩溃了,这时候我就在docker上为他拉了一个oracle,解决了问题. docker的安装共有以下几步,实测没 ...

  8. oracle自动化,Oracle 自动化备份脚本

    备份脚本,基于linux,windows环境需要适当修改. 主脚本,会调用2,3步骤的rman.sql&status.sql $ more main.sh #set env ######### ...

  9. it oracle 培训,Oracle数据库技术培训_OracleDBA数据库工程师_Oracle数据库在线学习视频教程_IT职业培训-51CTO学院_精培学院...

    第一阶段:企业级Oracle数据库实战入门与集群实施 特色:本阶段部分内容为OCP/OCM课程内容,以企业实战项目为主导讲解,实用性更强. 第1章 Oracle数据库高级工程师职业发展与学习方法 第2 ...

  10. 【oracle】oracle经典sql,exception,database link纠错

    [oracle]oracle经典sql,exception,database link纠错 1111-01 oracle经典sql,exception,database link纠错 1.给表tabl ...

最新文章

  1. 【贪心】小Y的炮[cannon]题解
  2. 机器视觉-特征点检测:【2】Harrs角点检测原理
  3. kubernetes日志采集与解析
  4. java的程序控制关键字_Java编程的关键字有哪些
  5. 互联网寒冬:轮回之下,几人破茧,几人沉沦
  6. 【BDTC 2016】专访中兴飞流吕阿斌、郑龙:Yita,基于数据流的大数据计算引擎...
  7. ​​什么是图形工作站?我们日常接触的计算机类别
  8. 小白python爬虫入门实例2—— 翻页爬取京东商城商品数据
  9. 证书信任管理器(用于https请求) X509TrustManager
  10. GC基本原理学习(Garbage Collected)
  11. 别错过,教你如何用电脑玩手机
  12. 解决关闭浏览器后再打开,访问网站仍然自动登陆的问题
  13. mysql中一次字符集和排序规则引起的sql查询报错
  14. 提交代码到git仓库
  15. 爬虫在遇到post请求时的一种解决{“code“:40005,“msg“:“req json error“}问题的思路
  16. NBA历史上最长的连胜和连败纪录!
  17. config是什么?
  18. react路由hash转brower访问页面,页面空白
  19. wordpress升级PHP7.2 安装WP Keyword Link出现PHP Warning: Use of undefined constant action - assumed 'action
  20. 前端面经——html篇

热门文章

  1. coolfire文章之八
  2. html用锚点回到顶部代码,纯css实现回到顶部-jq回到顶部方法
  3. 下载编译LineageOS代码
  4. Linux+ps进程解释,linux ps查看进程命令详解
  5. 八皇后-韩顺平java
  6. Linux服务器操作系统 . 文件目录及文件管理
  7. python表白代码-python告白代码,只属于程序员的浪漫
  8. 《JavaScript 学习指南》
  9. foremost windows_windows上安装foremost - kalibb
  10. bt磁力种子与php文件,BT,种子和磁力链接