Rank function returns the rank of each row within the partition
Syntax
RANK () OVER ([PARTITION BY CLAUSE] ORDER BY CLAUSE)
Example
The following example get the rank value from the studentmarks table using the rank function and partition by clause.
You can also get the rank function by removing the partition by clause.
The rank function will skip the rank order if the order by clause column having same value.
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.So the rank 2 will be skipped in this case.
No comments:
Post a Comment