Self Join Employees Table Salary Comparison

Find employees who earn more than their manager.

sql

SELECT e.name FROM employees e JOIN employees m ON e.manager_id = m.id WHERE e.salary > m.salary;

This query performs a self-join on the "employees" table to compare the "salary" of each employee with the "salary" of their respective manager, returning the names of those who earn more.

PromptDB can make mistakes. Please double-check responses.