TAILIEUCHUNG - advanced sql Functions in Oracle 10G phần 4

Giá trị cr 9 cho hàng 7 xảy ra bởi vì các xếp hạng của 7 đã được trao cho tất cả các hàng lên đến hàng thứ chín, và do đó hàng 7, 8, và 9 cùng giá trị của 9 cho cr, tử số trong tính toán chức năng. PERCENT_RANK và CUME_RANK chức năng rất chuyên ngành và đến nay ít phổ biến hơn | The Analytical Functions in Oracle Analytical Functions I The value of nr here is 20 20 rows . By the row the CUME_RANK calculation is CNAME TEMP RANK rownum cr calculation CD Binghamton 20 1 1 1 1 20 .050 New Milford 24 2 2 2 2 20 .100 Provo 44 6 6 6 6 20 .300 Reston 47 7 7 9 9 20 .450 Alexandria 47 7 8 9 9 20 .450 Idaho Falls 47 7 9 9 9 20 .450 Grass Valley 55 10 10 10 10 20 .500 Baton Rouge 58 11 11 13 13 20 .650 Starkville 58 11 12 13 13 20 .650 Carrboro 58 11 13 13 13 20 .650 Brewton 72 17 17 17 17 20 .850 Gulf Breeze 77 18 19 19 19 20 .950 Davenport 77 18 19 19 19 20 .950 Orlando 79 20 20 20 20 20 The cr value of 9 for row 7 occurs because the rank of 7 was given to all rows up to the ninth row and hence rows 7 8 and 9 get the same value of 9 for cr the numerator in the function calculation. The PERCENT_RANK and CUME_RANK functions are very specialized and far less common than RANK or RoW_NUMBER. Also in our examples we have depicted only one grouping one partition. A PARTITION BY clause may be added to the analytic clause of the function and sub-grouping and sub-PER-CENT_RANKs and CUME_DISTs may also be reported. 108 Chapter I For example using our Employee table with PERCENT_RANK and CUmE_DiST SELECT empno ename region RANK OVER PARTITION BY region ORDER BY curr_salary RANK PERCENT_RANK OVER PARTITION BY region ORDER BY curr_salary PR CUME_DIST OVER PARTITION BY region ORDER BY curr_salary CD FROM employee Gives EMPNO ENAME REGION RANK PR CD 108 David E 111 Katie E 122 Lindsey E 101 John W 102 Stephanie W 106 Chloe W 104 Christina W 1 0 .333333333 2 .5 .666666667 311 1 0 .25 2 .333333333 .75 2 .333333333 .75 411 In this result first note the partitioning by region The result set acts like two different sets of data based on the partition. Within each region we see the calculation of PERCENT_RANK and CUME_DIST as per the previous algorithms. 109 The Analytical Functions in Oracle Analytical Functions I References SQL for Analysis in Data Warehouses .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.