在每个经理下选择员工姓名,经理姓名,员工最高工资

时间:2017-02-17 10:32:31

标签: sql

enter image description here

我有上表,我想获得Employeename,经理名称,每个经理下的员工最高工资

提前致谢

2 个答案:

答案 0 :(得分:0)

select name as Employeename,(select t.name from table t where t.id=managerId) as ManagerName,(select max(u.sallary) from table u where u.managerId=managerId) as MaxSalary from table

这将为您提供预期的结果

答案 1 :(得分:0)

SELECT b.name,e.name as managerName,max(b.Salary)
FROM Employee b
JOIN Employee e ON b.Id= e.ManagerId