My Blog List

Wednesday, March 6, 2013

rank, dense_rank, row_number difference


select * from pt_test



NO,NAME
-21,hello
4,hello
1,hello2
4,hello2
5,hello
10,hello



select no, name, rank() over(order by no desc) all_rank,
                 row_number() over(order by no desc) row_number,
                 dense_rank() over(order by no desc) dense_rank
from pt_test


NO,NAME,ALL_RANK,ROW_NUMBER,DENSE_RANK
10,hello,1,1,1
5,hello,2,2,2
4,hello,3,3,3
4,hello2,3,4,3
1,hello2,5,5,4
-21,hello,6,6,5




No comments:

Post a Comment