Remove duplicate email records so that only one row remains for each unique email address.
Problem
You are given a table of email records. Some email addresses appear in multiple rows. Your task is to remove the duplicate rows so that each email address appears at most once.
When multiple rows share the same email address, keep one row and delete the rest. The exact row to keep is typically the one chosen by the problem's rule (for example, the lowest id or any one row if no tie-break is specified).
Return the cleaned result or the delete action required, depending on the SQL variant of the task.
Goal
Produce a solution that identifies duplicate email values efficiently and removes or filters them correctly.
Input Format
- A table containing at least an
idcolumn and anemailcolumn. - Multiple rows may share the same
emailvalue.
Output Format
- A result set or SQL operation that leaves only one row per distinct
email. - Duplicate email rows should be excluded or deleted according to the platform's SQL task format.
Constraints
- Emails are compared by exact value.
- Table size may be large enough that a naive row-by-row approach is undesirable.
- Preserve one representative row for each unique email.
Example 1
Input
id | email 1 | a@b.com 2 | c@d.com 3 | a@b.com
Output
id | email 1 | a@b.com 2 | c@d.com
Explanation
The email a@b.com appears twice, so one of the duplicate rows is removed and only a single row for that email remains.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.