题目2:MySQL----------Second Highest Salary
来源:互联网 发布:网络创世纪手机版安卓 编辑:程序博客网 时间:2024/05/16 13:58
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
.
# Write your MySQL query statement belowSELECT max(Salary) FROM Employee WHERE Salary < (SELECT max(Salary) FROM Employee)
题目解析:
SELECT max(Salary) FROM Employee WHERE 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.
0 0
- 题目2:MySQL----------Second Highest Salary
- MySQL-Second Highest Salary
- 【MySQL】【leetcode】 Second Highest Salary解题报告
- LeetCode:Second Highest Salary
- Leetcode: Second Highest Salary
- Second Highest Salary
- Second Highest Salary
- LeetCode Second Highest Salary
- Second Highest Salary
- Second Highest Salary
- Second Highest Salary Leetcode
- Leetcode: Second Highest Salary
- Second Highest Salary
- LeetCode Second Highest Salary
- Second Highest Salary
- Second Highest Salary
- leetcode176---Second Highest Salary
- 176 - Second Highest Salary
- 基于Redis实现分布式Session
- Debian用apt-get 安装软件时出现的问题!
- 黑马程序员_Java基础(方法,数组)
- FCkEditor编辑器漏洞(IIS 6.0)
- 模版方法模式
- 题目2:MySQL----------Second Highest Salary
- 《Java程序设计》第二次作业:MySQL数据库及Java操作MySQL数据库
- 开放接口平台 in Action(汇总目录)
- struts2配置详解
- 【Unity】技巧集合
- iOS开发笔记11--NO architectures to compile for (ONLY_ACTIVE_ARCH=YES,active arch=x86_64
- ArchLinux 2014.09.03 安装教程
- Java教程--写的很好--有链接大家链接到博客园vamei的空间看吧
- 详解 C++11 lambda表达式