Wednesday, April 1, 2015

How to get second-highest salary employees in a table



- Method 1

    select max(salary) from Employees
        where salary < (select max(salary) from Employees)

 - Method 2

 select MAX(salary) from Employees
    where salary not in(select MAX(salary) from Employees)


 - Method 3

select MAX(salary) from Employees
    where salary != (select MAX(salary) from Employees )

-Method 4
SELECT salary from Employee ORDER BY salary DESC LIMIT 1, 1;

No comments:

Post a Comment