DIFFERENCE BETWEEN RANK() AND DENSE_RANK()

I have the following table
 
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
 
select empid, empname, age, RANK() over (order by age desc) as Rank 
from [dbo].[Employee]
 

 
 
select empid, empname, age, DENSE_RANK() over (order by age desc) as DenseRank 
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().

6 comments:

Petterjohn said...

The seller managed tasks well throughout the timeline.
Interactive design firms were so pleased that they brought the developer on to figure within their core team.

Mark Waji said...

Hmm!! This blog is really cool, I’m so lucky that I have reached here and got this awesome information.
web design firm

Southeast addiction said...

Your blog is extremely brilliant especially the quality content is really appreciable.
UX design firms

Thomas Joe said...

In addition to having great project management skills from top web design agencies , the team takes their work personally and cares about the project.

Margie Jones said...

Organized, responsive, and proactive in their approach, they continue to be great partners to work with.
interaction design firms

Gadget Portal said...

This is really an excellent blog as well as its content.
SF design studio