# Write your MySQL query statement below SELECT( SELECT DISTINCT Salary SecondHighestSalary FROM Employee ORDER BY Salary DESC Limit 1,1) AS SecondHighestSalary;
注意
limit x,y为显示第x行往后的的y行(包括第x行,序号从0开始)
由于存在多个最高薪水,DISTINCT是必要的
外围再加一个select是因为没有第二高薪水时要输出null
其他解法
1 2 3 4
#通过子查询去掉最大数再查询最大数 SELECTmax(Salary) SecondHighestSalary FROM Employee where Salary != (selectmax(Salary) from Employee );