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

Departments With at Least One Employee

Return the names of departments that have at least one employee, without returning a department more than once. Order by name.

Table schema

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

Sample data

Departments: (1, Eng), (2, HR), (3, Legal)
Employees department_ids: 1, 1, 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.