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 )

  

 

posted @ 2018-11-01 11:33  IT路上的小白  阅读(98)  评论(0编辑  收藏  举报