Skip to main content

182. Duplicate Emails

Số lượt xem trang

Giới thiệu bài toán​

Chi tiết: https://leetcode.com/problems/duplicate-emails

Table: Person

Column NameType
idint
emailvarchar
  • id is 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: Person table:
idemail
1[email protected]
2[email protected]
3[email protected]
  • Output:
Email
[email protected]

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/