---
title: "Difference between RANK() and DENSE_RANK() in sql server."  
description: "Difference between RANK() and DENSE_RANK() in sql server."  
author: "Manish Kumar"  
published: 2017-11-23  
updated: 2017-11-23  
canonical: https://www.mindstick.com/forum/34366/difference-between-rank-and-dense_rank-in-sql-server  
category: "mssql server"  
tags: ["database", "sql server"]  
reading_time: 1 minute  

---

# Difference between RANK() and DENSE_RANK() in sql server.

can [anyone tell me](https://www.mindstick.com/interview/23033/can-anyone-tell-me-about-hadoop-toolbox) that what is the main [difference](https://www.mindstick.com/articles/157114/good-news-or-bad-news-and-the-difference-is) between [RANK](https://www.mindstick.com/forum/33707/what-is-the-difference-between-rank-and-dense_rank-functions-in-sql-server)() and DENSE-RANK() ...

thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by Sunil Singh

RANK Function skips rankings if there is a tie where as DENSE_RANK willnot

For example

If you have 2 rows at rank 1 and you have 5 rows in total

Rank() returns-1, 1, 3, 4, 5

DENSE_RANK RETURN - 1, 1, 2, 3 ,4

\

lets take an example to understand

![Difference between RANK() and DENSE_RANK() in sql server.](https://www.mindstick.com/mindstickforums/463d256f-cd5f-414b-8097-c69aef00d11f/images/b2cc68d5-157a-44cb-a308-a8d4e23ba5b3.png)

##### Using rank()

select Name,salary,

rank() over (Order by Salary desc) as [rank] from salary

##### Using dense_rank()

select Name,salary,

dense_rank() over (Order by Salary desc) as [rank] from salary

##### output

![Difference between RANK() and DENSE_RANK() in sql server.](https://www.mindstick.com/mindstickforums/463d256f-cd5f-414b-8097-c69aef00d11f/images/4924f76b-07e3-4e65-9821-1417484aa710.png)\


---

Original Source: https://www.mindstick.com/forum/34366/difference-between-rank-and-dense_rank-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
