Employee Earnings
MediumPremium
You are given the employees table:
Find employees who are earning more than their managers. Output the employee’s first name along with their corresponding salary. Your output should have the following columns: first_name (of the employee), manager_salary.
WITH managers as
(SELECT id AS manager_id, salary AS manager_salary
FROM employees)
SELECT first_name, manager_salary
FROM employees a
LEFT JOIN
managers b
ON a.manager_id = b.manager_id
WHERE a.salary > b.manager_salary;
select e.first_name as first_name, m.salary as manager_salary from employees e join employees m on e.manager_id = m.id where e.salary > m.salary;