当前位置:网站首页>Leetcode: 184. the highest paid employee in the Department
Leetcode: 184. the highest paid employee in the Department
2022-07-22 18:59:00 【A master of East and West】
The original title is :https://leetcode-cn.com/problems/department-highest-salary/
Personal solution :
benefit use window mouth Letter Count : Using window functions : benefit use window mouth Letter Count :
select Department.Name as Department, e1.Name as Employee, e1.Salary
from (
select *
from (
select *, dense_rank() over(partition by DepartmentId order by Salary Desc) as ranking
from Employee
) as temp
where temp.ranking = 1
) as e1
left join Department
on e1.DepartmentId = Department.Id
where Department.Id IS NOT NULL;
Be careful Department Special cases without any data in the table , Therefore, it needs to be judged Department.Id IS NOT NULL;
Official solution :
bright spot : two individual word paragraph One rise I N Bright spot : Two fields together IN bright spot : two individual word paragraph One rise IN
SELECT
Department.name AS 'Department',
Employee.name AS 'Employee',
Salary
FROM
Employee
JOIN
Department ON Employee.DepartmentId = Department.Id
WHERE
(Employee.DepartmentId , Salary) IN
( SELECT
DepartmentId, MAX(Salary)
FROM
Employee
GROUP BY DepartmentId
)
;
边栏推荐
- Summary of various materials - Network
- 练习7-4 找出不是两个数组共有的元素(C语言)
- 交叉熵损失函数
- Shell $*和[email protected]的区别
- Important knowledge points of go language: string, UTF-8 encoding, Rune
- Vlfeat, pydot configuration
- 分库分表
- PTA 6-11 find the median of self-determined type element sequence (25 points)
- The detailed analysis of the divide () method in BigDecimal takes you into the world of source code
- Leetcode 116. fill in the next right node pointer of each node
猜你喜欢
1.Qt之打包发布程序 (NSIS);
Leetcode 105. constructing binary trees from preorder and inorder traversal sequences
Learning to Incorporate Structure Knowledge for Image Inpainting
bjyx
Wechat scans the QR code of the website, but only displays the link address, and cannot jump to the web page
numpy 求矩阵非零元素的均值
程序员面试金典面试题 01.01. 判定字符是否唯一
VLFeat、pydot配置
Flink学习笔记(三)Flink安装部署
递归求简单交错幂级数的部分和 (15分)
随机推荐
Leetcode 654. maximum binary tree
Qt | 模态对话框和非模态对话框 QDialog
sql 语法中 join 的所有用法总结(简单例子)
1. Where is the date for qdate (), 2. QT_ Usage Summary of version
QT | modal dialog and modeless dialog qdialog
Vlfeat, pydot configuration
JUC-同步器
1.雷点:mysql数据库转移到oracle,2.qt5.12.3 连接oracle 12c数据库
Leetcode 693. alternating bit binary number
C语言 static和extern知识点
LeetCode 2028. 找出缺失的观测数据
Flink learning notes (III) Flink installation and deployment
图像质量评价
paper - A Physics-based Noise Formation Model for Extreme Low-light Raw Denoising
Randomly query n pieces of data in various databases
Summary 20220211
1.mysql null 和 in;2.127.0.0.2是啥?
leetCode笔记
Leetcode 114. expand binary tree into linked list
numpy.reshape完成图像切割