Filter Employees Table by Department Count

Find departments having more than 5 employees.

sql

SELECT department_name, COUNT(id) AS employee_count FROM employees GROUP BY department_name HAVING COUNT(id) > 5;

This query groups the records in the "employees" table by "department_name" and uses the HAVING clause to filter for groups where the count of "id" exceeds 5.

PromptDB can make mistakes. Please double-check responses.