SQL Notes: Delete Duplicate Emails

XuanKhanh Nguyen
Nothingaholic
Published in
1 min readSep 26, 2021

--

196. Delete Duplicate Emails

Problem

Write an SQL query to delete all the duplicate emails, keeping only one unique email with the smallest Id.

Return the result table in any order.

The query result format is in the following example.

Example 1:

Input: 
Person table:
+----+------------------+
| Id | Email |
+----+------------------+
| 1 | john@example.com |
| 2 | bob@example.com |
| 3 | john@example.com |…

--

--

XuanKhanh Nguyen
Nothingaholic

Interests: Data Science, Machine Learning, AI, Stats, Python | Minimalist | A fan of odd things.