[LeetCode] [SQL]: 182: Duplicate Emails

题目:

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.

分析:分组(Group by) 加 统计(Count)即可

SQL

SELECT Email
FROM Person
GROUP BY Email Having count(*)>1
时间: 2024-10-16 23:39:30

[LeetCode] [SQL]: 182: Duplicate Emails的相关文章

[LeetCode][SQL]Delete Duplicate Emails

https://leetcode.com/problems/delete-duplicate-emails/ Delete Duplicate Emails Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+ | Id | Emai

leetcode 182. Duplicate Emails

传送门 182. Duplicate Emails My Submissions Question Total Accepted: 14498 Total Submissions: 38364 Difficulty: Easy Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Email | +----+---------+ | 1 | [email pr

LeetCode-Algorithms #007 Reverse Integer, Database #182 Duplicate Emails

LeetCode-Algorithms #007 Reverse Integer 给定一个32位整数, 将其各位反转并返回, 如果结果超出取值范围就返回0 1 class Solution { 2 public int reverse(int x) { 3 //对原数取绝对值 4 int y = Math.abs(x); 5 //将原数转换为字符串 6 String s1 = Integer.toString(y); 7 //将字符串转换为字符数组 8 char[] arr = s1.toCha

leetcode 196. Delete Duplicate Emails

196. Delete Duplicate Emails Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+ | Id | Email | +----+------------------+ | 1 | [email protect

LeetCode 182. Duplicate Emails (查找重复的电子邮箱)

题目标签: 题目给了我们一个 email 的table,让我们找到重复的 email. 可以建立 Person a, Person b, 找到两个表格中,emai 相等 但是 id 不同的 email, 然后利用DISTINCT 返回,因为两个表格中,会找到两个 重复的email. Java Solution: Runtime:  224 ms, faster than 40 % Memory Usage: N/A 完成日期:06/01/2019 关键点:用DISTINCT # Write yo

【Leetcode】Delete Duplicate Emails

题目链接:https://leetcode.com/problems/delete-duplicate-emails/ 题目: Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +--+------+ | Id | Email | +--+------+ | 1 | [email 

LeetCode Database: Delete Duplicate Emails

Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+ | Id | Email | +----+------------------+ | 1 | [email protected] | | 2 | [email protected]

Leetcode 196. Delete duplicate Emails. (Database)

Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id. +----+------------------+ | Id | Email | +----+------------------+ | 1 | [email protected] | | 2 | [email protected]

LeetCode 196. Delete Duplicate Emails (删除重复的电子邮箱)

题目标签: 题目给了我们一个 email 的表格,让我们删除重复的. 建立Person p1,Person p2,当email 相同时,而且 p1 id 要大于 p2 id 时候,删除这一行. Java Solution: Runtime:  869 ms, faster than 33 % Memory Usage: N/A 完成日期:06/01/2019 关键点:p1.Id > p2.Id # Write your MySQL query statement below DELETE p1