176. Second Highest Salary#1
来源:互联网 发布:自学日语教材知乎 编辑:程序博客网 时间:2024/05/17 07:11
Solutin#1
# Write your MySQL query statement belowSELECT MAX(Salary) AS SecondHighestSalaryFROM EmployeeWHERE 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.
Solution#2
SELECT (SELECT DISTINCT SalaryFROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET 1) AS SecondHighestSalary #利用了Limit 1,同时在外圈加一圈选择满足了Null的情况
0 0
- 176. Second Highest Salary#1
- 176. Second Highest Salary
- 176. Second Highest Salary
- 176. Second Highest Salary
- 176. Second Highest Salary
- 176. Second Highest Salary
- 176. Second Highest Salary
- 176. Second Highest Salary
- leetcode 176. Second Highest Salary
- leetcode 176. Second Highest Salary
- leetcode.176. Second Highest Salary
- leetcode 176. Second Highest Salary
- Leetcode 176. Second Highest Salary
- leetcode 176. Second Highest Salary
- leetcode 176. Second Highest Salary
- 176. Second Highest Salary(Leetcode)
- [理解leetcode解法]176. Second Highest Salary
- 【leetcode Database】176. Second Highest Salary
- liunx 查看网卡驱动信息
- 胶囊体阴影
- String字符串用法集合
- hdu3625 Examining the Rooms && hdu4372 Count the Buildings(第一类斯特林数)
- 二分图匹配
- 176. Second Highest Salary#1
- 转载:如何使用Maven新建项目,自动打依赖jar包
- SVN学习笔记
- 在Windows 10系统下卸载Oracle 11g
- 如何用Baas快速在腾讯云上开发小程序-系列1:搭建API & WEB WebSocket 服务器
- hibernate oracle 配置uuid
- matlab
- jQuery的deferred对象详解
- Spark mmlib开发中遇到的问题