Find Duplicate Names in Departments Table

Find departments that have duplicate department names.

sql

SELECT name, COUNT(*) FROM departments GROUP BY name HAVING COUNT(*) > 1;

This query groups the records in the "departments" table by the "name" column and filters the results to return only those names that appear more than once.

PromptDB can make mistakes. Please double-check responses.