176. Second Highest Salary
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 query should return 200 as the second highest salary. If there is no second highest salary, then the query should return null.
+---------------------+
| SecondHighestSalary |
+---------------------+
| 200 |
+---------------------+ 查找第二高的薪水,如果不存在,则返回null MySQL(989ms):
# Write your MySQL query statement below
SELECT MAX(Salary) AS SecondHighestSalary
FROM Employee
WHERE Salary < (SELECT MAX(Salary)
FROM Employee) ;
176. 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 176. Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...
- 【SQL】176. Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...
- LeetCode 176. Second Highest Salary (第二高的薪水)
题目标签: 题目给了我们一个工资表,让我们返回第二高的工资. 利用Max,把第一高的工资找到,然后利用 NOT IN,去找到第二高的工资. Java Solution: Runtime: 153ms ...
- LeetCode_Mysql_Second Highest Salary
176. Second Highest Salary 1. 问题描写叙述: 写一个sql语句从 Employee 表里获取第二高位的工资. 2. 解决思路: 这道题非常easy,就当热身了.首先用ma ...
- [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 ...
- leetcode Database3(Nth Highest Salary<—>Consecutive Numbers<—>Department Highest Salary)
一.Nth Highest Salary Write a SQL query to get the nth highest salary from the Employee table. +----+ ...
随机推荐
- java中new一个对象放在循环体里面与外面的区别
首先说下问题: 这次在做项目的是出现了一个new对象在循环里面与外面造成的不同影响. 大家可以看到这个new的对象放在不同的位置产生的效果是不一样的. 经过多方查询与验证可以得出结论: * EasyU ...
- like tp
$where['insurance_order_num'] = array('like',$insurance_order_num.'%'); //右边模糊搜索,2099032902309张三 和 2 ...
- maven中用yuicompressor和closure-compiler对js、css文件进行压缩
转载自:http://matychen.iteye.com/blog/1477350 项目采用maven构建的时候,需要压缩js,css等,网上找了相关资料,自己综合了下- 直接放代码: <! ...
- mysql 修改max_connections
1.使用命令show variables 来查看当前最大连接数 show variables like '%max_connections%'; 使用命令set global max_connecti ...
- ES6中函数的扩展
一.设置默认参数 ES6之前,给函数设置默认参数是这样做的: function fn(a) { if(typeof y === undefined){ a = a || 'hello'; } cons ...
- npm 淘宝镜像安装以及安装报错window_nt 6.1.7601 解决
http://www.cnblogs.com/ycxhandsome/p/6562980.html npm config set proxy null npm config set https-pro ...
- Makefile $@,$^,$ 作用
/* main.c */ #include "mytool1.h" #include "mytool2.h" int ...
- 01-QQ 3-最终重构版
Demo示例程序源代码
源代码下载链接:01-QQ 3.zip292.5 KB // QQAppDelegate.h Map // // QQAppDelegate.h // 01-QQ // // Created ...
- html+js实现的触屏版贪吃蛇
查看线上demo(服务器经常断开,推荐下载源码本地打开): http://47.93.103.19:8044/client/ ; 使用手机打开或者chrome浏览器的手机模式打开 源码地址 :http ...
- adb操作指令大全
adb是什么?:adb的全称为Android Debug Bridge,就是起到调试桥的作用.通过adb我们可以在Eclipse中方面通过DDMS来调试android程序,说白了就是debug工具.a ...