Microsoft SQL Server 2005 Best Practices

How to find the second highest salary?

 

Execute the following script in Query Editor to find the 2nd highest pay:

USE AdventureWorks;

SELECT TOP 1 Rate FROM (SELECT TOP 2 Rate FROM HumanResources.EmployeePayHistory
WHERE PayFrequency = 2 ORDER BY Rate DESC ) a
ORDER BY Rate

GO


 

The Best SQL Server 2005 Training in the World
 
 
SQLUSA.com Home Page