Skip to content

Latest commit

 

History

History
44 lines (34 loc) · 810 Bytes

README.md

File metadata and controls

44 lines (34 loc) · 810 Bytes

LC-182 - Duplicate Emails

Create table If Not Exists Person (Id int, Email varchar(255))
Truncate table Person
insert into Person (Id, Email) values ('1', '[email protected]')
insert into Person (Id, Email) values ('2', '[email protected]')
insert into Person (Id, Email) values ('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] |
+---------+
  • Difficulty: EASY

Notes

  • All emails are in lowercase.

Solutions

  1. Using GROUP BY and a temporary table
  2. Using GROUP BY and HAVING condition