当前位置:网站首页>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道
边栏推荐
- Coco test dev test code
- Why do people like to rank things
- 【RYU】安装RYU常见问题及解决办法
- 哈希表与一致性哈希的原理理解以及应用
- Getlocation:fail the API need to be declared in the requiredprivateinfo field in app.json
- How to do the system security test? Let's talk about it in detail
- MySQL 5.7 takes the first item of the group
- 抖音服务器带宽有多大,才能供上亿人同时刷?
- Database read-write separation and database and table segmentation
- 一道数学题,让芯片巨头亏了5亿美金!
猜你喜欢

单例模式(双检锁)
![[redis] five common data types](/img/0f/17945b6f3a7735d9a569296c2c0e2a.png)
[redis] five common data types

MySQL master-slave database configuration based on docker for Ubuntu
![[redis] quick start](/img/42/09f08b4f78bc2ddd4d15693d62cb4b.png)
[redis] quick start

Compile and use protobuf Library in vs2019

Play a parallel multithreaded mcu-mc3172

Ten thousand words long text, take you to understand the kubernetes network model

智能指针shared_ptr、unique_ptr、weak_ptr

Database read-write separation and database and table segmentation

How big is the bandwidth of the Tiktok server for hundreds of millions of people to brush at the same time?
随机推荐
2649: 段位计算
数据库读写分离和分库分表
[动态规划中等题] LeetCode 198. 打家劫舍 740. 删除并获得点数
Play a parallel multithreaded mcu-mc3172
OD-Paper【3】:Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks
Talk about connection pools and threads
红宝书第四版的一个错误?
阿里云技术专家杨泽强:弹性计算云上可观测能力的构建
用最原始的方法纯手工实现常见的 20 个数组方法
如何白嫖最新版BurpSuite Pro
Okaleido tiger is about to log in to binance NFT in the second round, which has aroused heated discussion in the community
Favicon网页收藏图标在线制作PHP网站源码/ICO图片在线生成/支持多种图片格式转换
Okaleido Tiger 7.27日登录Binance NFT,首轮已获不俗成绩
Kubernetes Dashboard 部署应用以及访问
银河证券基金低佣金开户靠谱吗,可靠安全吗
[redis] quick start
2513: 小勇学分数(公约数问题)
Inftnews | ggac and China Aerospace ases exclusively produce "China 2065 Collection Edition"
Rust Web(一)—— 自建TCP Server
Manually build ABP framework from 0 -abp official complete solution and manually build simplified solution practice