Reputation: 1417
One table with EmpSalary in Employee Table. I need to find the second largest Salary what is paid by the company.?
How to find the Second largest value(Salary) from a table.?
Upvotes: 3
Views: 6957
Reputation: 1417
select top(1) prodMrp from Product where not prodMrp = (select top(1) prodMrp from Product order by prodMrp DESC ) order by prodMrp DESC
Upvotes: -1
Reputation: 348
Try this: this should give the second largest salary:
SELECT MAX(EmpSalary) FROM employee WHERE EmpSalary < (SELECT MAX(EmpSalary) FROM employee);
Upvotes: 3
Reputation: 6547
;WITH CTE AS ( SELECT ROW_NUMBER() OVER (ORDER BY SortColumn DESC) AS RowNumber, *
FROM YourTable)
SELECT * FROM CTE WHERE RowNumber = 2
Upvotes: 7