美文网首页
176. 第二高的薪水

176. 第二高的薪水

作者: bangbang2 | 来源:发表于2020-07-11 14:28 被阅读0次
image.png

解题思路

看看有什么难点呢?

limit没搞过?note:0为first line
limit 5,10 ----5为begin line,10为offset ---其实就是取几行啦
limit 5----0-4 lines ----默认0开始数五行
limit 1 offset 1,相信你也会啦!

ifnull是什么呀?
翻翻官方文档
ifnull(expr1,expr2)
if expr1 is not null,return expr1
else return expr2

image.png

nullif是啥呢?
nullif(expr1,expr2)
if expr1=expr2 return null
else return expr1


image.png

if(expr1,expr2,expr3)
这玩意和三目运算符一样


image.png

代码

# Write your MySQL query statement below
select
ifnull((select Employee.Salary
from Employee
Group by Salary desc
limit 1 offset 1),null) as SecondHighestSalary ;

相关文章

网友评论

      本文标题:176. 第二高的薪水

      本文链接:https://www.haomeiwen.com/subject/urkicktx.html