2nd Highest Salary in SQL Server

2nd Highest Salary using max function: 
  1. select MAX(ID) from Employees where ID NOT IN (Select MAX(ID) from Employees)  
  2. select MAX(ID) from Employees where ID < (Select MAX(ID) from Employees ) 
Using Top we can retrieve nth highest salary: 
  1. select top 1 ID from (select top 2 ID from Employees order by id descas tblEmployee order by ID ASC  
  2.    
  3.  Using dense_rank to retrieve 2nd Highetst salary if we have duplicate rows:  
  4.    
  5. with CTETable  
  6. as  
  7. (  
  8. select ID, Name, DENSE_RANK() over (order by ID descas Rnk from Employees  
  9. )  
  10. select Name, ID from CTETable where rnk=2