TreeviewCopyright © aleen42 all right reserved, powered by aleen42

182. 查找重复的电子邮箱

https://leetcode-cn.com/problems/duplicate-emails/

MySQL

# Write your MySQL query statement below

# HAVING 是在 GROUP BY 之后做一个补充筛选,而分组选用的字段是Email,
# 所以 COUNT(*) 函数是针对 Email 里面的内容进行分别计数, 即 COUNT(*) > 1 表示指定 email 的出现次数不止一次
SELECT Email FROM Person GROUP BY Email HAVING COUNT(*) > 1

SQLServer

/* Write your T-SQL query statement below */

/* 首先使用 group by 进行数据汇总,其次使用 having 进行过滤: 使用 count(字段) 进行统计汇总数据,大于1的则为重复 */
SELECT Email FROM Person GROUP BY Email HAVING COUNT(Email) > 1
Copyright © GoogTech 2021 all right reserved,powered by GitbookLast update time : 2021-09-15 01:55:05

results matching ""

    No results matching ""