Back to Practice
#0029
Find Duplicate Emails
EasySQL10 min10 XP
Problem
Write a query that returns each duplicate email and how many times it appears.
Why This Matters
Duplicate detection is a practical data quality task and a very common SQL interview warm-up.
Schema
users(id, email)
Examples
Example 1
Inputa@test.com appears twice, b@test.com appears once
Outputa@test.com, 2
Only emails with count greater than 1 are duplicates.
Constraints
- Return email and email_count.
- Sort by email ascending.
- Use COUNT(*).
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 4 hidden categories
One duplicate email
Inputthree users, one repeated email
Expecteda@test.com count 2
HAVING COUNT(*) > 1 keeps duplicate groups.
Hidden Test Categories
No duplicatesMultiple duplicate emailsThree or more occurrencesCase-sensitive email values