Can you describe a self-join in SQL and provide a scenario where it would be useful?
Using an employees table, demonstrate the concept by returning employees who have a matching direct manager. Provide a PostgreSQL query and briefly explain why this pattern is useful.
employee_name, manager_name, and departmentmanager_name, then employee_name alphabetically| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee's full name |
| manager_id | INT | Employee identifier of the direct manager |
| department | VARCHAR(100) | Employee department |