JOIN + GROUP BY + COUNT.
Return the department name and employee count for each department that has employees. Columns: `department_name`, `headcount`. Order by department name. Tables: `ci_employees`, `ci_departments`.
| Column | Type | Key |
|---|---|---|
| id | INT | PK |
| name | TEXT | |
| department_id | INT | FK → ci_departments.id |
| manager_id | INT | FK → ci_employees.id |
| salary | INT | |
| hire_date | DATE |
| Column | Type | Key |
|---|---|---|
| id | INT | PK |
| name | TEXT |
Each hint you reveal reduces the XP you can earn. Try the query first.
JOIN ci_employees to ci_departments on department_id.
GROUP BY the department name.