CUME-DIST()和PERCENT-RANK()函式

wmlm發表於2007-04-23

下面這個例子說明了CUME-DIST()與PERCENT-RANK()的使用,它得到的是銷量的累積分佈和百分比排名:

[@more@]

SQL>select prd_type_id,sum(amount),

cume_dist() over(order by sum(amount) desc) as cume_dist,

percent_rank() over(order by sum(amount) desc) as percent_rank

from all_sales

where year=2003

group by prd_type_id

PRD_TYPE_ID

SUM(AMOUNT)

CUME_DIST

PERCENT_RANK

5

null

.142857143

0

4

699054.57

.285714286

.166666667

1

349535.92

.428571429

.333333333

7

349529.76

.571428571

.5

6

349529.66

.714285714

.666666667

2

349527.34

.857142857

.833333333

3

349526.62

1

1

7 rows selected.

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

相關文章