How to find the second highest value from a table.?

One table with EmpSalary table in employee table. I need to find the second largest salary that the company paid.

How to find the second highest value (Salary) from the table.?

+3
source share
3 answers

Try the following: this should give the second highest salary:

SELECT MAX (EmpSalary) FROM employee WHERE EmpSalary <(SELECT MAX (EmpSalary) FROM employee);

+3
source
;WITH CTE AS ( SELECT ROW_NUMBER() OVER (ORDER BY SortColumn DESC) AS RowNumber, * 
               FROM YourTable)
SELECT * FROM CTE WHERE RowNumber = 2
+7
source

top (1) prodMrp Product, prodMrp = ( top (1) prodMrp prodMrp DESC) order by prodMrp DESC

-1

Source: https://habr.com/ru/post/1770080/


All Articles