【SQL】177. Nth Highest Salary
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
.
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
set N=N-1;
RETURN (
# Write your MySQL query statement below.
select distinct Salary
from Employee
order by Salary desc
limit N,1
);
END
【SQL】177. Nth Highest Salary的更多相关文章
- 【SQL】184. Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a colu ...
- 【SQL】176. Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...
- LeetCode 177. Nth Highest Salary
https://leetcode.com/problems/nth-highest-salary/description/ Write a SQL query to get the nth highe ...
- leetcode - database - 177. Nth Highest Salary (Oracle)
题目链接:https://leetcode.com/problems/nth-highest-salary/description/ 题意:查询出表中工资第N高的值 思路: 1.先按照工资从高到低排序 ...
- 177. Nth Highest Salary
问题描述 解决方案 CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT BEGIN declare number int; set numbe ...
- [SQL]LeetCode177. 第N高的薪水 | Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- 【sql】leetcode习题 (共 42 题)
[175]Combine Two Tables (2018年11月23日,开始集中review基础) Table: Person +-------------+---------+ | Column ...
- [LeetCode] Nth Highest Salary 第N高薪水
Write a SQL query to get the nth highest salary from the Employee table. +----+--------+ | Id | Sala ...
- 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. +----+ ...
随机推荐
- table表格frame属性
定义和用法 frame 属性规定外侧边框的哪个部分是可见的. 从实用角度出发,最好不要规定 frame,而是使用 CSS 来添加边框样式. 浏览器支持 除了 Internet Explorer,其他浏 ...
- HDU 4500 小Q系列故事——屌丝的逆袭
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4500 解题报告:简单题,数据范围不大,直接暴力每个点,然后再比较出得分最大的点的位置和分数. #inc ...
- POJ 2485 Highways( 最小生成树)
题目链接 Description The islandnation of Flatopia is perfectly flat. Unfortunately, Flatopia has no publ ...
- 图片压缩之 PNG
作者:程志达链接:https://zhuanlan.zhihu.com/p/19570424来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. PNG(Portable N ...
- mvc 分部视图(Partial)显示登陆前后变化以及Shared文件夹在解决方案资源管理器中没有显示的问题
刚开始我的解决方案资源管理器中没有显示Shared文件夹,但Shared文件夹在项目中是实际存在的,我搜了下好像没有类似的解答(可能是我搜索的关键词不够准确).后来自己看了下vs2012. 其实解决方 ...
- MySQL 四种链接
1.内联接 INNER JOIN(典型的联接运算,使用像 = 或 <> 之类的比较运算符).包括相等联接和自然联接. 内联接使用比较运算符根据每个表共有的列的值匹配两个表中的行. ...
- Ubuntu 18.04安装MongoDB 4.0(社区版)
Ubuntu 18.04(虚拟机VirtualBox上),MongoDB 4.0, 听室友说,23点有世界杯决赛呢!可是,孤要写博文的啊!以记录这忙乱的下午和晚间成功安装了一个软件到Linux上.—— ...
- java基础18 String字符串和Object类(以及“equals” 和 “==”的解析)
一.String字符串 问:笔试题:new String("abc")创建了几个对象?答:两个对象,一个对象是 位于堆内存,一个对象位于字符串常量池 class Demo17 { ...
- 洛谷P2018消息传递
传送门啦 这个树形dp就没那么简单了,运用了一下贪心的思想 不同的排序方法对应着不同的转移方程,如果我们用 $ f[x] = max(f[x] , b[i] +cnt - i + 1) $ 来进行转移 ...
- RobotCraft 2017 第二届国际机器人学暑期学校 2nd Edition of International Robotics Summer School
原文网址:http://www.ros.org/news/2017/02/2nd-edition-of-international-robotics-summer-school-robotcraft- ...