PERCENTILE-DISC(X)函式

wmlm發表於2007-04-23
PERCENTILE-DISCX)函式[@more@]

PERCENTILE-DISCX)函式與CUME-DIST相反,它在每一個分組中檢查累積分佈的數值,直到找到大於或等於X的值。

PERCENTILE-CONTX)函式與PERCENT-RANK()相反,在每一個分組中檢查百分比排名的值,直到

找到大於或等於X的值。

下面我們來看個例子獲取百分點大於等於0.6的銷售總量:

SQL> SELECT

2 PERCENTILE_CONT(0.6) WITHIN GROUP (ORDER BY SUM(amount) DESC) AS percentile_cont,

3 PERCENTILE_DISC(0.6) WITHIN GROUP (ORDER BY SUM(amount) DESC) AS percentile_disc

4 FROM all_sales

5 WHERE year=2003

6 GROUP BY prd_type_id;

PERCENTILE_CONT PERCENTILE_DISC

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

417855.11 402751.16

以上是網友的筆記,以下是我的試驗:

select percentile_cont(0.1) within group (order by sum(amount) desc) as percentile_cont,

percentile_disc(0.1) within group (order by sum(amount) desc) percentile_disc

from all_sales

group by prd_type_id;

PERCENTILE_CONT PERCENTILE_DISC

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

1435184.13 1889959.57

Nnd 暫時不知道用在何處?

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/271063/viewspace-912072/,如需轉載,請註明出處,否則將追究法律責任。

相關文章