【问题标题】:Percentile_cont / OraclePercentile_cont / 甲骨文
【发布时间】:2013-08-07 16:39:05
【问题描述】:

我正在使用percentile_cont 来查找分布的百分位数。我的桌子是:

Class_id    RollNum Marks 
1             1        10
1             2        12
1             3        16
1             4        08
1             5        17

我正在使用查询

SELECT class_id, 
       percentile_cont(0.05) within group (order by marks) as marksPerntl 
  from myTable group by class_id

现在可以查询得到百分位数的卷号吗?

【问题讨论】:

  • 鉴于您发布的表数据,您的查询不会运行 - 它以 ORA-00937: not a single-group group function : SELECT class_id, percentile_cont(0.05) within group (order by marks) as marksPerntl from myTable 失败。 SQLFiddle here。请编辑您的问题并更正数据、发布工作代码或添加其他说明。谢谢。
  • 您好,缺少按语法分组。我现在已经编辑了这个问题。谢谢

标签: sql oracle plsql oracle11g plsqldeveloper


【解决方案1】:

PERCENTILE_CONT 函数对值进行插值,为您提供Marks 的值,该值将落入分布中的 5% 百分位。

使用上述数据运行查询将返回(@Bob Jarvis 评论中的SQLFiddle):

| CLASS_ID | MARKSPERNTL |
--------------------------
|        1 |         8.4 |

您的数据集不包含Marks8.4 的任何行。因此,没有一个 RollNum 值获得百分位数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-05
    • 2011-07-19
    • 2014-09-11
    • 2011-06-15
    • 2020-06-10
    • 2018-08-20
    相关资源
    最近更新 更多