SQL problem - Duplicate Emails
Problem
Query
Note:
- because
WHEREcannot be used with theGROUP BY, that’s why we haveHAVINGclause.
SELECT
email
FROM
Person
GROUP BY email
HAVING COUNT(email) > 1
Editorial Solution
Approach 1: Using GROUP BY and Subquery
select Email from
(
select Email, count(Email) as num
from Person
group by Email
) as statistic
where num > 1
;
