Categories:

Tags:



Problem

Table: Person

+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| id          | int     |
| email       | varchar |
+-------------+---------+
id is the primary key column for this table.
Each row of this table contains an email. The emails will not contain uppercase letters.

Write an SQL query 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.

Solution

The problem Duplicate Emails can be solved using keywords GROUP BY and HAVING.

Implementation

# Write your MySQL query statement below

SELECT email AS Email
FROM person
GROUP BY email
HAVING COUNT(id) > 1;