Sir, I have a table name tbl_Employee
the contents are:-
emp.ID Name Salary
05 John 5000
08 Rose 4000
10 Mathew 6000
I want to display emp.Id ,Name and Salary of employee whom salary is second highest in this table
please send me the SQL Query
Display Second highest value in a Table in SQL Server
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.


Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 6, 2013, 9:03 PM EDT
Pankaj PandeyRank #642 · 3.7K reputationPosted Jun 6, 2013, 8:30 PM EDT
try it ..
SELECT * FROM (
SELECT ROW_NUMBER() OVER (ORDER BY SALARY DESC) AS rownumber,Salary
FROM tbl_Employee)
AS foo
WHERE rownumber = 2
Bineesh ViswanathRank #1,681 · 907 reputationPosted Jun 6, 2013, 8:51 PM EDT
The Code is working correctly, but is there any query to display emp.Id and salary instead of row number and salary in the above query?
Bineesh ViswanathRank #1,681 · 907 reputationPosted Jun 6, 2013, 9:15 PM EDT
This is absolutely correct answer to my question