LeetCode 184. Department Highest Salary(找出每个部门中最高薪水)

第一种情况:普通情况

第二种情况:

 

第三种情况:

 

 

结果:

select

t1.Name as Employee,t1.Salary as Salary,t2.Name as Department

from

Employee t1 left join Department t2 on t1.DepartmentId=t2.Id

where (t1.DepartmentId,t1.Salary) in (select t4.DepartmentId, max(t4.salary) as s from Employee t4 group by t4.DepartmentId) and t2.Id is not null

posted @ 2017-12-27 14:47  哒哒哒大大诚  阅读(131)  评论(0编辑  收藏  举报