176. Second Highest Salary

原题链接:https://leetcode.com/problems/second-highest-salary/description/
又是一道数据库题目。我写下了如此的实现:

# Write your MySQL query statement below
select Salary as SecondHighestSalary from Employee order by Salary limit 1, 1;

然而,有些情况并不能运行正确。无奈之下,去看官方解答吧:

select (select distinct Salary from Employee order by Salary desc limit 1, 1) as SecondHighestSalary;

select ifnull((select distinct Salary from Employee order by Salary desc limit 1, 1), null) as SecondHighestSalary;

官方答案就是牛逼啊,我的 sql 玩的还是不够溜。。。

原文地址:https://www.cnblogs.com/optor/p/8622173.html