LeetCode Second Highest Salary 第二高薪水

我用的SQL  当时也没有想那么多,关键是后面有为NULL的情况,当时没有考虑到

select rownum ,a.Salary ,a.Id from ( select * from Employee group by Salary,Id) a where a.rownum = 2

这个是看了别个写的,慢慢地我想出来了

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

  

原文地址:https://www.cnblogs.com/cb1186512739/p/9888312.html