185. 部门工资前三高的所有员工
题目链接:185. 部门工资前三高的所有员工
代码如下:
# Write your MySQL query statement below
select d.Name as 'Department',e1.Name as 'Employee',e1.Salary
from Employee as e1
join Department as d
on e1.DepartmentId=d.Id
where 3>(select count(distinct e2.Salary)from Employee e2where e2.Salary>e1.Salaryand e1.DepartmentId=e2.DepartmentId
)