0
点赞
收藏
分享

微信扫一扫

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


​Employee​

+----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+


​200​​. If there is no second highest salary, then the query should return ​​null​​.

题目答案:

# 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.








举报

相关推荐

题目>>mysql>>1

C语言题目2

案例题目.2

题目2 快乐消消乐

C语言题目记录2

0 条评论