Help us understand the problem. What is going on with this article?

Oracleでパーセンタイル(百分位数)を求める

More than 1 year has passed since last update.
ID T_VALUE
1 2.3
2 4.5
3 3.3
4 1.2
5 9.5
6 7.3
7 6.2
8 3.8
9 5.1
10 8.9

このようなテーブルがあったとする。(テーブル名は「TARGET」とする)

SELECT
    MAX(T_VALUE)                                              AS pmax,
    PERCENTILE_CONT(0.99) WITHIN GROUP (ORDER BY T_VALUE ASC) AS p99,
    MEDIAN(T_VALUE)                                           AS pmed,
    PERCENTILE_CONT(0.01) WITHIN GROUP (ORDER BY T_VALUE ASC) AS p1,
    MIN(T_VALUE)                                              AS pmin
FROM TARGET

結果は

pmax p99 pmed p1 pmin
9.5 9.446 4.8 1.299 1.2

ちなみに「PERCENTILE_CONT」はExcel関数の「PERCENTILE.INC」と同じ計算結果となる。

nac731
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away