LeetCode SQL: Second Highest Salary
select if(count(salary) = 0, NULL, salary) as `salary` from (
select salary from Employee group by salary order by salary desc limit 1,1) tmp
Write a SQL query to get the second highest salary from the Employee
table.
+----+--------+
| Id | Salary |
+----+--------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
+----+--------+
For example, given the above Employee table, the second highest salary is 200
. If there is no second highest salary, then the query should return null
.
对于null的处理稍烦
LeetCode SQL: Second Highest Salary的更多相关文章
- LeetCode 176 Second Highest Salary mysql,select 嵌套 难度:1
https://leetcode.com/problems/second-highest-salary/ Write a SQL query to get the second highest sal ...
- LeetCode 177. Nth Highest Salary
https://leetcode.com/problems/nth-highest-salary/description/ Write a SQL query to get the nth highe ...
- Leetcode 176. Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...
- LeetCode DB: Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
- [LeetCode#184]Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
- LeetCode 176. Second Highest Salary (第二高的薪水)
题目标签: 题目给了我们一个工资表,让我们返回第二高的工资. 利用Max,把第一高的工资找到,然后利用 NOT IN,去找到第二高的工资. Java Solution: Runtime: 153ms ...
- [LeetCode] Department Highest Salary 系里最高薪水
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
- [LeetCode] Nth Highest Salary 第N高薪水
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- [LeetCode] Second Highest Salary 第二高薪水
Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...
随机推荐
- 3.1 High Availability
摘要: 出处:黑洞中的奇点 的博客 http://www.cnblogs.com/kelvin19840813/ 您的支持是对博主最大的鼓励,感谢您的认真阅读.本文版权归作者所有,欢迎转载,但请保留该 ...
- 后序线索化二叉树(Java版)
前面介绍了前序线索化二叉树.中序线索化二叉树,本文将介绍后序线索化二叉树.之所以用单独的一篇文章来分析后序线索化二叉树,是因为后序线索化二叉树比前序.中序要复杂一些:另外在复习线索化二叉树的过程中,大 ...
- 开源系统-edusoho在线教育
#部署 ```bash [root@localhost ~]# docker run --name edusoho -tid -p 9900:80 -e DOMAIN= ...
- string容器的简单实现
1.业务使用main.cpp #include "pch.h" #include <iostream> int main() { mystring s1;//无参构造函 ...
- word里的字号与html字号的对应关系
在word里输入一段文字,把文字调成需要的大小,即"三号或者小三",然后把文件另存为网页,在格式里选择“html”格式,然后把word关闭,将另存的html文件用编辑工具打开,就可 ...
- angluarjs的tab标签
JS代码 $scope.tabs = []; $rootScope.data = { current: "3" // 1代表张三,2代表李四,3代表王五 }; $rootScope ...
- HDU - 6133 启发式合并
题意:给出一棵树共\(n\)个顶点,每个顶点有一个权值\(val_i\),你需要对每个节点统计一个最优解 每个节点的解按照一定规则产生:取出该节点的子树下所有的顶点,把顶点任意排序成一个序列,设为\( ...
- remote link Centos6.6 Horrible Slow
客户端win7 , 本地直连,secureCRT连接Centos6.6 速度巨慢,FTP tool almost cannot link in. 即使用cmd ftp 也是反应30s以上.
- 快速排序分析及实现(C++)
目录 快速排序算法分析及实现(C++) 算法思想 快速排序步骤 优点分析 C++语言实现 快速排序算法分析及实现(C++) 算法思想 把n个元素划分为三段:左端Left,中间段middle和右端r ...
- 利器推荐-Snipaste截图工具
利器推荐-Snipaste截图工具 一.引言 接触这个工具之前一直用QQ的ctrl+alt功能进行截图,但是有时候QQ没有登陆,或者没网的环境就没法使用:这时候可能会使用windows自带的截图工具, ...