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

Department Headcount

Count the number of employees in each department. Return department_id and employee_count, ordered by employee_count descending, then department_id ascending.

Table schema

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

Sample data

id | name  | department_id
1 | Alice | 1
2 | Bob | 1
3 | Carol | 2
4 | Dan | 3
5 | Eve | 2
6 | Frank | 1

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.