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 ...
随机推荐
- [Swift实际操作]八、实用进阶-(3)闭包在定时任务、动画和线程中的使用实际操作
闭包的使用相当广泛,它是可以在代码中被传递和引用的具有独立功能的模块.双击打开之前创建的空白项目.本文将演示闭包在定时任务.动画和线程中的使用.在左侧的项目导航区,打开视图控制器的代码文件:ViewC ...
- mxonline实战2, 后台管理神器xadmin
对应github地址:xadmin的使用 第三天:xadmin的安装以及各应用模型的后台管理注册 一. 安装xamdin 1. 源码包下载地址 https://gith ...
- Rabbitmq 消息对列 生产者与消费者的具体实现 springboot
RabbitMQ 基本介绍 RabbitMQ的设计理念是.只要有接收消息的队列. 邮件就会存放到队列里. 直到订阅人取走. . 如果没有可以接收这个消息的消息队列. 默认是抛弃这个消息的.. 我实现的 ...
- trunc 函数用法
转载至:http://blog.csdn.net/aqszhuaihuai/article/details/6303686 1.trunc用于日期,可精确到年,月和日. select trunc(sy ...
- Linux之Ubuntu中的安装应用
在Ubuntu中我们经常会使用apt install “APP name” 来安装需要的应用. 从图中我们可以看到,我们使用apt install map命令安装一个map小游戏,这个小游戏是一个用四 ...
- 永久激活navicat_premium12.0,支持win32和64位
1.下载软件以及注册机 链接:https://pan.baidu.com/s/1NGc6YLsgMQRQYEwnGSU16Q 提取码:guno 2.根据自己的电脑位数安装对应的软件,傻瓜式安全(注 ...
- Python unittest第二篇:测试夹具
关于测试夹具,我们知道,以类为对象的话,在python里对应的方法分别是test_isupper.test_upper, 那么以测试case为单位呢? 这时候,就要提到我们的setup()和tearD ...
- Q239 滑动窗口最大值
给定一个数组 nums,有一个大小为 k 的滑动窗口从数组的最左侧移动到数组的最右侧.你只可以看到在滑动窗口 k 内的数字.滑动窗口每次只向右移动一位. 返回滑动窗口最大值. 示例: 输入: nums ...
- (转)drbd详解
原文:http://blog.csdn.net/u014421556/article/details/52925442
- java处理数据库的CRUD
package com.lhy.jdbc.util; import java.sql.Connection; import java.sql.PreparedStatement; import jav ...