-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path182.duplicate-emails.sql
50 lines (47 loc) · 978 Bytes
/
182.duplicate-emails.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
--
-- @lc app=leetcode id=182 lang=mysql
--
-- [182] Duplicate Emails
--
-- https://leetcode.com/problems/duplicate-emails/description/
--
-- database
-- Easy (61.22%)
-- Likes: 466
-- Dislikes: 25
-- Total Accepted: 185K
-- Total Submissions: 298K
-- Testcase Example: '{"headers": {"Person": ["Id", "Email"]}, "rows": {"Person": [[1, "[email protected]"], [2, "[email protected]"], [3, "[email protected]"]]}}'
--
-- Write a SQL query to find all duplicate emails in a table named Person.
--
--
-- +----+---------+
-- | Id | Email |
-- +----+---------+
-- | 1 | [email protected] |
-- | 2 | [email protected] |
-- | 3 | [email protected] |
-- +----+---------+
--
--
-- For example, your query should return the following for the above table:
--
--
-- +---------+
-- | Email |
-- +---------+
-- | [email protected] |
-- +---------+
--
--
-- Note: All emails are in lowercase.
--
--
-- @lc code=start
-- Write your MySQL query statement below
SELECT Email
FROM Person
GROUP BY Email
HAVING COUNT(Email) > 1
-- @lc code=end