Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Employees per Department Including Empty Ones

Return every department name with its employee count, including departments with zero employees. Order by department name.

Table schema

Departments(id INT PRIMARY KEY, name VARCHAR(50))
Employees(id INT PRIMARY KEY, name VARCHAR(50), department_id INT)

Sample data

Departments:
id | name
1 | Engineering
2 | HR
3 | Legal

Employees:
id | name | department_id
1 | A | 1
2 | B | 1
3 | C | 2

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.