Skip to content

Commit 9b5c1fd

Browse files
committed
task: #196
1 parent 9397d28 commit 9b5c1fd

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Have a good contributing!
3838
- [181. Employees Earning More Than Their Managers](./leetcode/easy/181.%20Employees%20Earning%20More%20Than%20Their%20Managers.sql)
3939
- [182. Duplicate Emails](./leetcode/easy/182.%20Duplicate%20Emails.sql)
4040
- [183. Customers Who Never Order](./leetcode/easy/183.%20Customers%20Who%20Never%20Order.sql)
41+
- [196. Delete Duplicate Emails](./leetcode/easy/196.%20Delete%20Duplicate%20Emails.sql)
4142
- [511. Game Play Analysis 1](./leetcode/easy/511.%20Game%20Play%20Analysis%201.sql)
4243
- [577. Employee Bonus](./leetcode/easy/577.%20Employee%20Bonus.sql)
4344
- [586. Customer Placing the Largest Number of Orders](./leetcode/easy/586.%20Customer%20Placing%20the%20Largest%20Number%20of%20Orders.sql)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Question 196. Delete Duplicate Emails
3+
Link: https://leetcode.com/problems/delete-duplicate-emails/description/
4+
5+
Table: Person
6+
7+
+-------------+---------+
8+
| Column Name | Type |
9+
+-------------+---------+
10+
| id | int |
11+
| email | varchar |
12+
+-------------+---------+
13+
id is the primary key (column with unique values) for this table.
14+
Each row of this table contains an email. The emails will not contain uppercase letters.
15+
16+
17+
Write a solution to delete all duplicate emails, keeping only one unique email with the smallest id.
18+
19+
For SQL users, please note that you are supposed to write a DELETE statement and not a SELECT one.
20+
21+
For Pandas users, please note that you are supposed to modify Person in place.
22+
23+
After running your script, the answer shown is the Person table. The driver will first compile and run your piece of code and then show the Person table. The final order of the Person table does not matter.
24+
*/
25+
26+
DELETE FROM Person
27+
WHERE id NOT IN (
28+
SELECT MIN(id)
29+
FROM Person
30+
GROUP BY email
31+
)

0 commit comments

Comments
 (0)