当前位置:Gxlcms > 数据库问题 > 题目2:MySQL----------Second Highest Salary

题目2:MySQL----------Second Highest Salary

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

# Write your MySQL query statement below
SELECT max(Salary) FROM Employee WHERE Salary < (SELECT max(Salary) FROM Employee)

题目解析:

SELECT max(Salary) FROM Employee WHERE Salary < (SELECT max(Salary) FROM Employee)

Using max() will return a NULL if the value doesn‘t exist. So there is no need to UNION a NULL. Of course, if the second highest value is guaranteed to exist, using LIMIT 1,1 will be the best answer.







题目2:MySQL----------Second Highest Salary

标签:database   leetcode   sql   mysql   

人气教程排行