当前位置:网站首页>开窗函数(1)-部门工资前三员工
开窗函数(1)-部门工资前三员工
2022-07-24 18:20:00 【阿松丶】
已知表

题目
公司的主管们感兴趣的是公司每个部门中谁赚的钱最多。一个部门的 高收入者 是指一个员工的工资在该部门的 不同 工资中 排名前三 。
编写一个SQL查询,找出每个部门中 收入高的员工 。
以 任意顺序 返回结果表。
示例

参考答案
select
base.Department,
base.Employee,
base.Salary
from
(select
b.name as 'Department',
a.name as 'Employee',
a.salary as 'Salary',
dense_rank() over(partition by a.departmentId order by a.salary desc) as 'salary_rank'
from
Employee a
join
Department b
on
a.departmentId = b.id
) as base
where
base.salary_rank <=3
来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/department-top-three-salaries
边栏推荐
- Wu Enda writes: how to establish projects to adapt to AI career
- [opencv] - thresholding
- Get the original data API on 1688app
- Common methods of number and math classes
- 如何向 google colab 快速上传文件
- Section 11 cache avalanche, hot data failure follow Daewoo redis ------- directory post
- 运维小白成长记——架构第8周
- Still building projects from scratch? This upgraded rapid development scaffold is worth a try!
- 0701~ holiday summary
- JMeter -- prometheus+grafana server performance visualization
猜你喜欢

安装JumpServer

About the writing method of interface 1 chain interpretation 2. Method execution (finally) must be executed

In depth analysis of the famous Alibaba cloud log4j vulnerability

Typora 它依然是我心中的YYDS 最优美也是颜值最高的文档编辑神器 相信你永远不会抛弃它

Shanghai Jiaotong University team used joint deep learning to optimize metabonomics research
去不图床容量兑换
![[OBS] dependency Library: x264 vs Build](/img/24/4caea5dc6ff092a3161f43b6026d25.png)
[OBS] dependency Library: x264 vs Build

继承与派生

【OpenCV】—阈值化

6126. 设计食物评分系统
随机推荐
0614~放假自习
0621~ES&Lucene
0623~ holiday self study
05mysql lock analysis
In depth analysis of the famous Alibaba cloud log4j vulnerability
ORM introduction and database operation
0701~ holiday summary
Just one dependency to give swagger a new skin, which is simple and cool!
redis集群的三种方式
JumpServer的使用
0630~ professional quality course
0627~ holiday knowledge summary
JMeter -- prometheus+grafana server performance visualization
如何向 google colab 快速上传文件
How to read "STL source code analysis"?
颜色的13 个必备方法!
JMeter -- silent operation
Example of single table query in ORM student management system
T245982 "kdoi-01" drunken flower Yin
Icml2022 Best Paper Award: learning protein reverse folding from millions of predicted structures