Employees
I need to arrange them in order of their seniority. Their are two ways to do this. In the first case we use the RANK() function
from [dbo].[Employee]
select empid, empname, age, DENSE_RANK() over (order by age desc) as DenseRank
from [dbo].[Employee]
from [dbo].[Employee]
If we notice the difference, the first result set doesn't have rank 4. The reason if to people have the same rank, DENSE_RANK() gives the next immediate rank whereas RANK() doesn't. Hence Jack has a rank of 4 via DENSE_RANK() but 5 via RANK().
No comments:
Post a Comment