leetcode-database-177. Nth Highest Salary
来源:互联网 发布:软件著作是什么意思 编辑:程序博客网 时间:2024/06/05 08:06
Write a SQL query to get the nth highest salary from the Employee
table.
+----+--------+| Id | Salary |+----+--------+| 1 | 100 || 2 | 200 || 3 | 300 |+----+--------+
For example, given the above Employee table, the nth highest salary where n = 2 is
200
. If there is no nth highest salary, then the query should return null
.题意:查询第n高的记录,如果没有请返回null
思路:按照salary排正序,使用limit挑选出第N高
最终sql:
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
declare M INT;
set M=N-1;
RETURN (
select DISTINCT SALARY from Employee order by SALARY DESC LIMIT M,1
);
END
0 0
- leetcode-database-177. Nth Highest Salary
- 【leetcode Database】177. Nth Highest Salary
- leetcode 177. Nth Highest Salary
- leetcode.177. Nth Highest Salary
- leetcode 177. Nth Highest Salary
- Leetcode 177. Nth Highest Salary
- LeetCode Nth Highest Salary
- 【LeetCode】Second Highest Salary && Nth Highest Salary
- LeetCode | Second Highest Salary & Nth highest salary
- leetcode SQL题目 177. Nth Highest Salary
- 177. Nth Highest Salary
- leetcode 177 Nth Highest Salary
- [LeetCode][Database]Second Highest Salary
- [LeetCode][Database]Department Highest Salary
- 【leetcode】database Second Highest Salary
- Database LeetCode Second Highest Salary
- Database LeetCode Department Highest Salary
- [LeetCode]Nth Highest Salary,解题报告
- Java 的移位运算
- microsoft office 2013安装及激活
- leetcode-database-178. Rank Scores
- 乌兰电站调速器发货
- Tomcat配置https及访问http自动跳转至https
- leetcode-database-177. Nth Highest Salary
- 事件
- 自包含
- 缺少编译器要求的成员“System.Runtime.CompilerServices.ExtensionAttribute..ctor” 解决方案
- leetcode-shell-195. Tenth Line
- iOS 单元测试3- Singleton如何测试
- Android开发中无处不在的设计模式——Builder模式
- easyui combobox默认选中第一个
- 文件上传和下载功能