题目描述:
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] | +---------+ Note: All emails are in lowercase.
题目大意:
编写一个SQL查询从Person表中找出所有重复的邮箱地址。
例如,上表的查询结果应该返回[email protected]
所有的邮箱地址均为小写字母。
解题思路:
使用GROUP BY和HAVING即可
SQL语句:
# Write your MySQL query statement below
SELECT Email FROM Person GROUP BY Email HAVING COUNT(*) > 1
本文链接:http://bookshadow.com/weblog/2015/01/17/leetcode-duplicate-emails/
请尊重作者的劳动成果,转载请注明出处!书影博客保留对文章的所有权利。