IBM PureData System for Analytics, Version 7.1

Ranking function

The following is an example of a ranking function:
SELECT grp, a, sal, rank() OVER(partition by grp ORDER BY sal), 
dense_rank() OVER( partition by grp ORDER BY sal) FROM tab;
GRP  A   SAL RANK PERCENT_RANK DENSE_RANK
--- ---  --- ---- ----------   ---------- 
1   1    3000 1   0                     1
1   2    3000 1   0                     1
2   3    800  1   0                     1
2   4    950  2   .333333333            2
2   5    1100 3   .666666667            3
2   6    1300 4   1                     4
3   7    1250 1   0                     1
3   8    1250 1   0                     1
3   9    1500 3   .5                    2
3   10   1600 4   .75                   3
3   11   2500 5   1                     4
(11 rows)

In line 9 in the example, a rank is not skipped for the row when dense_rank is computed.



Feedback | Copyright IBM Corporation 2014 | Last updated: 2014-02-28