`

oracle聚合函数-----percent_rank()和cume_dist()指定分组序列相对位置

 
阅读更多
PERCENT_RANK ( expr [, expr]... ) WITHIN GROUP( ORDER BY
  expr [ DESC | ASC ] [NULLS { FIRST | LAST }]
  [, expr [ DESC | ASC ] [NULLS { FIRST | LAST }]]...)
返回指定数据在指定分组序列中所占的相对位置,不管指定值与分组序列中某值是否重复,均将此值视为序列一部分.

select percent_rank(2975) within group(order by scott.emp.sal) from scott.emp


CUME_DIST(expr[,expr]...) WITHIN GROUP(ORDER BY
    expr [DESC | ASC] [NULLS {FIRST | LAST}]
      [,expr [DESC | ASC] [NULLS {FIRST | LAST}]]...)
查询指定数值在指定分组序列中的相对位置,返回值是介于 0 和 1 之间的小数值。如果指定值与分组序列中某值重复,则将二值视为一个值处理。

select cume_dist(2975) within group(order by scott.emp.sal) from scott.emp
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics