Second Highest Salary

来源:互联网 发布:使命召唤10画面优化 编辑:程序博客网 时间:2024/05/29 03:24

Second Highest Salary

 

Write a SQL query to get the second highest salary from the Employee table.

+----+--------+| Id | Salary |+----+--------+| 1  | 100    || 2  | 200    || 3  | 300    |+----+--------+

For example, given the above Employee table, the second highest salary is 200. If there is no second highest salary, then the query should return null.

# Write your MySQL query statement below#select e1.Salary #from Employee e1 left join Employee e2 #on e2.Salary > e1.Salary   #order by e2.Salary desc limit 1;  select max(Salary) from Employeewhere Salary < (select max(Salary) from Employee);

0 0