181. Employees Earning More Than Their Managers

Return the names of employees who earn more than their manager, as Employee.

A self-join: the same table appears twice, once as the employee and once as the manager.

Lesson: joins.

Solutions

SELECT e.name AS Employee
FROM Employee e
JOIN Employee m ON m.id = e.managerId
WHERE e.salary > m.salary;