学习时间:
2023年3月1日
题目描述:




题解分享:
# 作 者 : 繁 华 倾 夏
# 力扣(LeetCode):185. 部门工资前三高的所有员工
# MySQL 数据库
select
d.Name as 'Department', e1.Name as 'Employee', e1.Salary
from
Employee e1
join
Department d on e1.DepartmentId = d.Id
where
3 > (select
count(distinct e2.Salary)
from
Employee e2
where
e2.Salary > e1.Salary
and e1.DepartmentId = e2.DepartmentId
)

该篇文章介绍了如何使用MySQL查询每个部门工资排名前三的员工信息。通过连接Employee和Department表,利用子查询计算每个部门中比当前员工薪资高的人员数量,筛选出薪资排名前三的记录。
593

被折叠的 条评论
为什么被折叠?



