当前位置:网站首页>177. 第N高的薪水(简单)
177. 第N高的薪水(简单)
2022-07-27 00:43:00 【only-qi】
问题描述:
表: Employee
+-------------+------+
| Column Name | Type |
+-------------+------+
| id | int |
| salary | int |
+-------------+------+
Id是该表的主键列。
该表的每一行都包含有关员工工资的信息。
编写一个SQL查询来报告 Employee 表中第 n 高的工资。如果没有第 n 个最高工资,查询应该报告为 null 。
查询结果格式如下所示。
示例 :
示例 1:
输入:
Employee table:
+----+--------+
| id | salary |
+----+--------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
+----+--------+
n = 2
输出:
+------------------------+
| getNthHighestSalary(2) |
+------------------------+
| 200 |
+------------------------+
示例 2:
输入:
Employee 表:
+----+--------+
| id | salary |
+----+--------+
| 1 | 100 |
+----+--------+
n = 2
输出:
+------------------------+
| getNthHighestSalary(2) |
+------------------------+
| null |
+------------------------+
通过次数169,071
提交次数362,608
上sql,拿去即可运行:
table:
CREATE TABLE `test01` (
`id` int(100) NOT NULL AUTO_INCREMENT,
`salary` decimal(10,2) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;SELECT salary FROM `test01` group by salary order by salary asc limit 6,1test01test01我要刷300道算法题,第107道
边栏推荐
- Inftnews | "traffic + experience" white lining e Digital Fashion Festival leads the new changes of digital fashion
- Debezium series: pull historical data based on debezium offset to ensure that data is not lost
- 使用 WebSocket 实现一个网页版的聊天室(摸鱼更隐蔽)
- 软件测试面试常见问题及答案(发散思维、接口、性能、概念、)
- 抖音服务器带宽有多大,才能供上亿人同时刷?
- 手动从0搭建ABP框架-ABP官方完整解决方案和手动搭建简化解决方案实践
- Kubernetes Dashboard 部署应用以及访问
- 杀毒软件 clamav 的安装和使用
- 批量复制宝贝上传提示乱码,如何解决?
- [Ryu] common problems and solutions in installing Ryu
猜你喜欢

B-树的应用以及添加和删除操作

Baidu cloud face recognition

How to use devaxpress WPF to create the first MVVM application in winui?

智能指针shared_ptr、unique_ptr、weak_ptr

制作ppt时间轴

CAS deployment and successful login jump address

手动从0搭建ABP框架-ABP官方完整解决方案和手动搭建简化解决方案实践

万字长文,带你搞懂 Kubernetes 网络模型

论构造函数的原型是谁

Use the most primitive method to manually implement the common 20 array methods
随机推荐
2513: 小勇学分数(公约数问题)
static关键字
一个测试类了解BeanUtils.copyProperties
Ansible series: do not collect host information gather_ facts: False
OD-Paper【3】:Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
软件测试相关试题知识点
{“errcode“:44001,“errmsg“:“empty media data, hint: [1655962096234893527769663], from ip: 222.72.xxx.
Database knowledge required by testers: MySQL common syntax
B-树的应用以及添加和删除操作
Marqueeview realizes sliding display effect
iNFTnews | “流量+体验”白衬e数字时装节引领数字时装新变迁
Use of formdata
Common questions and answers of software testing interview (divergent thinking, interface, performance, concept,)
Okaleido tiger is about to log in to binance NFT in the second round, which has aroused heated discussion in the community
小玩一个并行多线程MCU—MC3172
毕业2年转行软件测试获得12K+,不考研月薪过万的梦想实现了
阿里云解决方案架构师张平:云原生数字化安全生产的体系建设
确定了,2022下半年软考报名8月开始
What did kubedmin do?
Arduinouno drive RGB module full color effect example