We have an employee salary table, how do we find the second highest from it ?

 Posted by Bharathi Cherukuri on 4/25/2012 | Category: Sql Server Interview questions | Views: 1799 | Points: 40

You can use the below query to find out the second highest salary from employee salary table.

SELECT * FROM TblEmployeeSalary a WHERE (2=(SELECT COUNT(DISTINCT(b.salary)) FROM TblEmployeeSalary b WHERE b.salary>=a.salary))

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Ras90it on: 4/26/2012 | Points: 10
Thank for Info.

Here What is meant by a & b. please explain clearly

Thanks in advance

Login to post response