What is the real time usage of RANK and DENSE_RANK


#1

Can anyone give clarification about RANK and DENSE_RANK, when they will be used in real time projects?


#2

While using RANK function if you have say 3 records having same rank of 1, then the 4th record will have rank of 4.
Example:
student_id,student_marks,rnk
101,500,1
103,500,1
107,500,1
102,450,4

Whereas if you use dense_rank you’ll get the rank in consecutive numbers.
Example:
student_id,student_marks,rnk
101,500,1
103,500,1
107,500,1
102,450,2

Hope that helps!


#3

I know how they work. But I want to know what is the real time use case of those two.