I have a users
table that has duplicate values in the employee_id
column. I need to list all rows with duplicate employee_ids, along with their names. I need to see all users with a duplicate employee_id
so I can de-conflict which values are valid.
SELECT name,employee_id
FROM users;
name | employee_id
-----------------------
jason 12345
tom 34567
jane 12345
will 01020
bill 12345
I need to return:
name | employee_id
-------------------------
jason 12345
jane 12345
bill 12345
I see similar questions, but I still can't get the correct syntax I need. With the below I am only getting one occurrence. I need all occurances with duplicate employee_id
like above.
SELECT employee_id, MAX(name)
FROM users
GROUP BY employee_id
HAVING COUNT(employee_id) > 1;