---
title: "Getting top5 salary excluding max salary"  
description: "Getting top5 salary excluding max salary"  
author: "Royce Roy"  
published: 2015-03-02  
updated: 2015-03-02  
canonical: https://www.mindstick.com/forum/12993/getting-top5-salary-excluding-max-salary  
category: "mssql server"  
tags: ["mysql"]  
reading_time: 1 minute  

---

# Getting top5 salary excluding max salary

I am working on a [project](https://www.mindstick.com/articles/105927/how-to-excel-at-managing-multiple-projects) where there is a [requirement](https://yourviews.mindstick.com/view/85169/becoming-an-influencer-requirement-of-skills-and-knowledge) to get TOP 5 salaries excluding [MAX](https://www.mindstick.com/articles/1155/count-max-min-function-in-excel) salary. Suppose MAX salary is 67000, then I have to show top five salaries excluding 67000.

## Replies

### Reply by Anonymous User

Hi,

SQL Server has **OFFSET** through which you can exclude first row, so you can just sort the records by salary in descending order and remove first row, it will give you what you want.

Here is the SQL Query that could help you:

```
select Salary from Employee ORDER BY salary DESC OFFSET 1 ROWS FETCH NEXT 5 ROWS ONLY
```

### Reply by Anonymous User

You can use ranking to get top 5 salaries excluding the highest salary

```
SELECT Top 5 Salary from (SELECT Salary, DENSE_RANK() OVER (ORDER BY Salary Desc) AS Rnk FROM Employee) as emp where emp.Rnk > 1
```

### Reply by Takeshi Okada

You can use below query to get your desired result

```
select Top 5 Salary from Employee where Salary < (select MAX(salary) from Employee) order by salary desc
```


---

Original Source: https://www.mindstick.com/forum/12993/getting-top5-salary-excluding-max-salary

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
