当前位置:Gxlcms > 数据库问题 > LeetCode 176. 第二高的薪水(MySQL版)

LeetCode 176. 第二高的薪水(MySQL版)

时间:2021-07-01 10:21:17 帮助过:21人阅读

  

2.用到的知识点

  

limit : limit可以接收两个参数   limit 10 或者 limit 0,10

   前者表示查询显示前10行

  后者表示从第0行的往后10行,也就是第1行到第10行

 

IFNULL(expression_1,expression_2);

  如果expression_1不为NULL 就显示自己,否则显示expression_2

  类似Java expression1 != null? expression1:expression2

3.最终的SQL语句 

select IFNULL
(

(select distinct Salary from Employee  order by Salary desc limit 1,1),(null)

) as SecondHighestSalary

  

LeetCode 176. 第二高的薪水(MySQL版)

标签:etc   order   sql查询   mit   pre   distinct   desc   一个   获取   

人气教程排行