Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to Find 'n' th Max salary

Author  Topic 

Bsurendra99
Starting Member

5 Posts

Posted - 2003-07-23 : 00:49:11
How to fine the n th Max salary of an employee table

n th like 10 th Max salary

pp
Starting Member

2 Posts

Posted - 2003-07-23 : 01:51:40
SELECT name
FROM Emp e1
WHERE 3 =
(SELECT COUNT(*)
FROM Emp e2
WHERE e2.salary >= e1.salary)

Go to Top of Page

joseph
Starting Member

10 Posts

Posted - 2003-07-23 : 05:52:27

select top 3 salary
from employee
order by salary desc

Go to Top of Page

SamC
White Water Yakist

3467 Posts

Posted - 2003-07-23 : 10:25:04
This query should list the 9th highest salary.

SELECT TOP 1 Name, Salary
FROM Mytable
WHERE Name NOT IN (SELECT TOP 8 FROM MyTable ORDER BY Salary DESC)
ORDER BY Salary DESC



Go to Top of Page
   

- Advertisement -