30. Employee and Their Manager
EasyJoinsINNER JOINself-join
An INNER JOIN keeps only rows that have a match on both sides. Here the match lives in the same table: each employee's manager_id points at another row's id, so we join employees to itself.
Task: for every employee who has a manager, return employee (the employee's name) and manager (their manager's name). Employees with no manager (manager_id IS NULL) are dropped automatically by the inner join.
Output columns, in this exact order: employee, manager. Order the rows by employee ascending.
Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…
This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases — 5test cases in all. A sloppy query that only fits the example won't pass.
SQL· SQLite · runs in your browser
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.