182. Duplicate Emails
Giới thiệu bài toán
Chi tiết: https://leetcode.com/problems/duplicate-emails
Table: Person
| Column Name | Type |
|---|---|
| id | int |
| varchar |
idis the primary key (column with unique values) for this table.- Each row of this table contains an email. The emails will not contain uppercase letters.
Yêu cầu
Write a solution to report all the duplicate emails. Note that it's guaranteed that the email field is not NULL.
Return the result table in any order. The result format is in the following example.
Example 1:
- Input:
Persontable:
| id | |
|---|---|
| 1 | a@b.com |
| 2 | c@d.com |
| 3 | a@b.com |
- Output:
a@b.com |
- Explanation:
a@b.comis repeated two times.
Giải quyết bài toán
SELECT email
FROM Person
GROUP BY email
HAVING COUNT(id) > 1;
Tham khảo: https://leetcode.com/submissions/detail/1039091405/