Duplicate Emails

Easy SQLGROUP BYHAVING

Problem

Schema: Person(id INT, email VARCHAR). Return all email addresses that appear more than once.

Example 1 Input: [[email protected], [email protected], [email protected]] Output: "[email protected]"

Constraints

Approach — Core Patterns

This is a Core Patterns problem. The idea: pick the data structure best matched to the constraints and solve it in one clean pass. Work through the reference code below line by line, then re-derive it yourself in the editor — that's how the pattern sticks.

Complexity: see the walkthrough below.

Solution code

SQL

SELECT email
FROM Person
GROUP BY email
HAVING COUNT(*) > 1;

Practice it

Reading a solution isn't the same as being able to write it under pressure. Open this problem in the in-browser editor, hide the solution, and solve it from scratch — your code runs against real test cases instantly.

Solve Duplicate Emails interactively → ← All solutions