CJCoding With Joseph
15free / daySign inCreate account

Who Heads Each Department

For each department, show the instructor who heads it. Return department (the department's name, aliased), then the head's first_name and last_name. The join column is head_instructor_id, which is not the usual direction: the department row points at the instructor. Business has no head yet and must not appear. Sort by department.

Expected result:

+------------------+------------+-----------+
| department       | first_name | last_name |
+------------------+------------+-----------+
| Biology          | Amara      | Diallo    |
| Computer Science | Grace      | Okafor    |
| English          | Helen      | Brooks    |
| Fine Arts        | Rafael     | Moreno    |
| Mathematics      | Samuel     | Whitaker  |
+------------------+------------+-----------+
5 rows
Hints3 available
Topics:
Joins
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sel, ins, desc)

Results

Run your SQL to see every statement's output here, then how it compares with the expected answer.

Not sure what is in a table? SHOW TABLES lists them and DESCRIBE students shows the columns — or open the database browser on the left.