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
SELECT MIN(EmployeeSalary)FROM (SELECT DISTINCT TOP (2) EmployeeSalary FROM Employee ORDER BY EmployeeSalary DESC)THAVING MIN(EmployeeSalary) <> MAX(EmployeeSalary);
Select top 1 *from(select top 2 salary from TblEmployee order by salary desc ) as total order by salary asc