题目:

leetcode# 第二高的薪水

我的解答:select distinct Salary from Employee order by Salary desc limit 1,1

问题点:不存在第二高则输出null,这个不会写

 

正确答案:select ifnull ((select distinct Salary from Employee order by Salary desc limit 1,1), null) as SecondHighestSalary

知识点:

1. ifnull(x,y),若x不为空则返回x,否则返回y,这道题y=null

2. limit offset, 页数

3. distinct  去重

相关文章: