这个题乍一看是有歧义的,他说的是比经理工资高的员工,然而答案是工资比自己的经理高的员工(看不懂英文,不知道英文是什么样的)
对同一张表进行两次查询,没见过as的话做不出来,也就是起别名
对于同一张表,查询员工的表将其命名为a,查询经理的表将其命名为b
第一次查询:查询员工和经理:
select * from Employee a, Employee b
where a.managerId = b.id
第二次查询:查询同事之间工资差距
select * from Employee a, Employee b
where a.salary > b.salary
那么两相结合,用and连接起来就好了:
select a.name
from Employee as a, Employee as b
where a.managerId = b.id
and a.salary > b.salary
当然你直接用上面这个代码是没法通过的,因为我说了你没见过as起别名的话这道题就做不了
select a.name as 'Employee'
from Employee as a, Employee as b
where a.managerId = b.id
and a.salary > b.salary
唉 工资