SQL problem - Duplicate Emails
Problem
Query
Note:
- because
WHERE
cannot be used with theGROUP BY
, that’s why we haveHAVING
clause.
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
;