LeetCode_Mysql_Second Highest Salary

LeetCode_Mysql_Second Highest Salary

176. Second Highest Salary

LeetCode_Mysql_Second Highest Salary


1. 问题描写叙述:

写一个sql语句从 Employee 表里获取第二高位的工资。

2. 解决思路:

这道题非常easy,就当热身了。首先用max找到最高工资。
然后去找小于最高工资里的最高工资就是第二高的工资。

3. sql语句:

select Max(Salary) 
from Employee 
where Salary < (select Max(Salary) from Employee)

4. 执行时间:

LeetCode_Mysql_Second Highest Salary


希望多多交流指正!