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 ...
随机推荐
- [Objective-C语言教程]类型定义:typedef(19)
Objective-C编程语言提供了一个名称为typedef的关键字,可以使用此关键字为类型指定新名称. 以下是为单字节数字定义术语BYTE的示例 - typedef unsigned char BY ...
- yum 安装和卸载
yum list列出资源库中特定的可以Linux Yum安装或更新以及已经安装的rpm包 安装 yum install 安装包关键字 卸载 yum remove 安装包名
- winserver2008安装tomcat+mysql+httpd+redis环境
1. 装tomcat和jdk http://www.cnblogs.com/SHI520/p/4546849.html 2. 安装mysql5.7 https://www.jb51.net/a ...
- URL中 # (hash)的含义
url中#(hash)的含义 hash 属性是一个可读可写的字符串,该字符串是 URL 的锚部分(从 # 号开始的部分) 1."#"代表网页中的一个位置.其右面的字符,就是该位置的 ...
- 【NOI2018】
总之国赛已经过了1个月了. 感谢北大当初给我的一本约救我狗命,不然国赛就要没学上了. 铜牌倒数十多名,我觉得我也是混到了一种境界. 虽然对于集训队已经失去梦想,但是,Day1全场堪称最低的21分,也是 ...
- windows 虚拟机VMware 安装linux系统注意事项!!!
1.主机CPU是否支持虚拟化技术? 启动 CPUZ 软件(如下图) 注: 32位系统查看使用CPUZ_x86软件 64位系统查看使用CPUZ_x64软件 启动后 ...
- iframe 解析
简介:iframe在日常的开发中经常用到,本随笔在参考http://blog.csdn.net/cuew1987/article/details/11265153的情况下,将对iframe的常用用法进 ...
- WCF系列教程之WCF服务配置
文本参考自:http://www.cnblogs.com/wangweimutou/p/4365260.html 简介:WCF作为分布式开发的基础框架,在定义服务以及消费服务的客户端时可以通过配置文件 ...
- Hibernate核心开发接口_SessionFactory详解
SessionFactory: a) 用来产生和管理Session b)通常情况下每个应用只需要一个SessionFactory c)除非要访问多个数据库的情况 d) 关注两个方法即: openS ...
- python-UDP传输模型
#!/usr/bin/python #coding=utf-8 #服务器端 from socket import * from time import ctime HOST="192.168 ...