Function : ROW_NUMBER
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
ROW_NUMBER
is ANSI SQL-99 Function.
ROW_NUMBER is same as RANK except in the event of a tie. ROW_NUMBER does not report duplicate values ,unlike RANK.
Following is the result of the RANK function:
SELECT EMPLOYEEID,departmentno,salary,RANK() OVER (ORDER BY salary desc) from employee2;
Note
that ties produce the same ranking number however their positions are counted
against subsequent rankings.
Following
is the result of the using ROW_NUMBER:
SELECT EMPLOYEEID,departmentno,salary,ROW_NUMBER()
OVER (ORDER BY salary desc) from employee2;
Note that even case of tie ROW_NUMBER assigns values sequentially. |
Pages
▼
No comments:
Post a Comment