15,177,283 members
See more: , +
i try to get top 5 salary and second highest salary from employees table but it shows me also lowest salaries

check this picture ssalry column
salary column[^]

and this is the output

output[^]

this is the queries which i try

SQL
```SELECT MAX(Salary) FROM Employees
WHERE Salary NOT IN (SELECT MAX(Salary) FROM Employees )

select top 5 salary from Employees;```
Posted
Updated 24-Jan-16 18:00pm
v3

## Solution 2

To get nth highest salary:

SQL
```SELECT TOP 1 salary
FROM (
SELECT DISTINCT TOP n salary
FROM employees
ORDER BY salary DESC) a
ORDER BY salary```

in above, replace n to 2 & you will get 2nd highest salary as you required.

And for top 5 salary list please try :

SQL
```SELECT DISTINCT TOP 5 salary
FROM employees
ORDER BY salary DESC```

SQL SERVER &#8211; Find Nth Highest Salary of Employee &#8211; Query to Retrieve the Nth Maximum value &#8211; Journey to SQL Authority with Pinal Dave[^]
v2

## Solution 1

I am not really sure if I understand what you want here but I will try and attempt. Are you looking for top 5 salaries from the table? If yes, doesn't this fit?

SQL
`select distinct top 5 salary from employees order by salary desc`
v2
super_user 24-Jan-16 23:08pm

yes i am looking for top 5 salaries .. but when i do this this shows me also lowest salaries like 2500 which is lowest salary and i want top 5 highest salaries
dan!sh 24-Jan-16 23:17pm

How many distinct salary values do you have in table?
super_user 24-Jan-16 23:12pm

???