Dense Rank function returns the rank of each row within the partition without having any gaps in the ranking.
Syntax
DENSE_RANK () OVER ([PARTITION BY CLAUSE] ORDER BY CLAUSE)
Example
The following example get the dense rank value from the studentmarks table using the dense rank function and partition by clause.
The dense rank function will not skip the rank order even if the order by clause column having same value.
You can also use the dense rank function by removing the partition by clause as shown below.
In above example you can see the rank value of the student john is repeating two times since he scored the same marks in both subjects.In Case of dense rank the next rank value will not be skipped.
No comments:
Post a Comment