Find Duplicate Rows
sqlSQLbeginnertips
List values that appear more than once, with how often each occurs.
SELECT email, COUNT(*) AS occurrences
FROM users
GROUP BY email
HAVING COUNT(*) > 1
ORDER BY occurrences DESC;Step 7 of 25 · SQL Interview Preparation for Beginners · Stage 3: Aggregates and joins
List values that appear more than once, with how often each occurs.
SELECT email, COUNT(*) AS occurrences
FROM users
GROUP BY email
HAVING COUNT(*) > 1
ORDER BY occurrences DESC;