Manoj Kumar Duraisamy
Get the second highest value from the table using SQL

We have table called Employee and It has some random records with EmployeeID,EmployeeName and Employee Salary. In that how you will get second highest salary using sql query

By Manoj Kumar Duraisamy in SQL on Jan 07 2023
  • Munib Butt
    Jan, 2023 12

    SELECT MIN(EmployeeSalary)
    FROM (SELECT DISTINCT TOP (2) EmployeeSalary
    FROM Employee
    ORDER BY EmployeeSalary DESC)T
    HAVING MIN(EmployeeSalary) <> MAX(EmployeeSalary);

    • 1
  • Digambar Bhandare
    Jan, 2023 28

    Select top 1 *from(select top 2 salary from TblEmployee order by salary desc ) as total order by salary asc

    • 0

Most Popular Job Functions