Your question is Self-Join for Hierarchies. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Write a query using a self-join to find employees who earn more than their managers.
Use the employees table and compare each employee's salary with the salary of the employee referenced by manager_id. Exclude employees without a manager or without a comparable salary.
employee_id, employee_name, employee_salary, manager_name, manager_salaryemployee_id ascending| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee's full name |
| manager_id | INT | Employee ID of the person's manager |
| salary | DECIMAL(12,2) | Annual employee salary |