Finding duplicate values in a SQL table

Technology CommunityCategory: SQLFinding duplicate values in a SQL table
VietMX Staff asked 3 years ago
Problem

We have a table

ID   NAME   EMAIL
1    John   asd@asd.com
2    Sam    asd@asd.com
3    Tom    asd@asd.com
4    Bob    bob@asd.com
5    Tom    asd@asd.com

I want is to get duplicates with the same email and name.

Simply group on both of the columns:

SELECT
    name, email, COUNT(*) as CountOf
FROM
    users
GROUP BY
    name, email
HAVING 
    COUNT(*) > 1