mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
update
This commit is contained in:
43
leetcode/problem/delete-duplicate-emails.html
Normal file
43
leetcode/problem/delete-duplicate-emails.html
Normal file
@@ -0,0 +1,43 @@
|
||||
<p>Table: <code>Person</code></p>
|
||||
|
||||
<pre>
|
||||
+-------------+---------+
|
||||
| Column Name | Type |
|
||||
+-------------+---------+
|
||||
| id | int |
|
||||
| email | varchar |
|
||||
+-------------+---------+
|
||||
id is the primary key column for this table.
|
||||
Each row of this table contains an email. The emails will not contain uppercase letters.
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p>Write an SQL query to <strong>delete</strong> all the duplicate emails, keeping only one unique email with the smallest <code>id</code>. Note that you are supposed to write a <code>DELETE</code> statement and not a <code>SELECT</code> one.</p>
|
||||
|
||||
<p>Return the result table in <strong>any order</strong>.</p>
|
||||
|
||||
<p>The query result format is in the following example.</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Example 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong>
|
||||
Person table:
|
||||
+----+------------------+
|
||||
| id | email |
|
||||
+----+------------------+
|
||||
| 1 | john@example.com |
|
||||
| 2 | bob@example.com |
|
||||
| 3 | john@example.com |
|
||||
+----+------------------+
|
||||
<strong>Output:</strong>
|
||||
+----+------------------+
|
||||
| id | email |
|
||||
+----+------------------+
|
||||
| 1 | john@example.com |
|
||||
| 2 | bob@example.com |
|
||||
+----+------------------+
|
||||
<strong>Explanation:</strong> john@example.com is repeated two times. We keep the row with the smallest Id = 1.
|
||||
</pre>
|
Reference in New Issue
Block a user