Find duplicate rows in SQL

Which emails are in the users table more than once?

SNP 024 #936 Filed sql

Group by the column that should be unique and keep the groups with more than one row:

sql
SELECT email, COUNT(*) AS times
FROM users
GROUP BY email
HAVING COUNT(*) > 1
ORDER BY times DESC;

To see the full rows, not just the counts, join back:

sql
SELECT u.*
FROM users u
JOIN (
  SELECT email FROM users GROUP BY email HAVING COUNT(*) > 1
) d ON d.email = u.email
ORDER BY u.email, u.id;