1. 문제
Write a SQL query to find all duplicate emails in a table named Person.
+----+---------+
| Id | Email |
+----+---------+
| 1 | a@b.com |
| 2 | c@d.com |
| 3 | a@b.com |
+----+---------+
For example, your query should return the following for the above table:
+---------+
| Email |
+---------+
| a@b.com |
+---------+
Note: All emails are in lowercase.
2. 답
SELECT Email
FROM Person
GrOUP BY Email
HAVING COUNT(Id) != 1
3. KEY POINT
- 중복된 것 출력 => GROUP BY 하여 COUNT 값이 1이 아닌 것 출력
'MySQL > 문제풀이' 카테고리의 다른 글
[HackerRank] Japan Population / Weather Observation Station 2 / Weather Observation Station 18 (0) | 2021.03.22 |
---|---|
[LeetCode] 175. Combine Two Tables (0) | 2021.03.22 |
[LeetCode] 620. Not Boring Movies (0) | 2021.03.22 |
[LeetCode] 595. Big Countries (0) | 2021.03.22 |
[LeetCode] CASE 테이블 피봇 : 1179. Reformat Department Table (0) | 2021.03.15 |
댓글