leetcode数据库sql之Delete Duplicate Emails
leetcode原文引用:
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 | john@example.com |
| 2 | bob@example.com |
| 3 | john@example.com |
+----+------------------+
Id is the primary key column for this table.
For example, after running your query, the above Person table should
have the following rows:
+----+------------------+
| Id | Email |
+----+------------------+
| 1 | john@example.com |
| 2 | bob@example.com |
+----+------------------+
我的sql语句:
DELETE FROM Person
WHERE
id NOT IN (SELECT
id
FROM
(SELECT
MIN(id) AS id
FROM
Person
GROUP BY email) AS a);
leetcode数据库sql之Delete Duplicate Emails的更多相关文章
- leetcode【sql】 Delete Duplicate Emails
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- [SQL]196. Delete Duplicate Emails
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- [LeetCode] Delete Duplicate Emails 删除重复邮箱
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- LeetCode——Delete Duplicate Emails(巧用mysql临时表)
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- 【SQL】182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...
- SQL Server Delete Duplicate Rows
There can be two types of duplication of rows in a table 1. Entire row getting duplicated because th ...
- [SQL]LeetCode196. 删除重复的电子邮箱 | Delete Duplicate Emails
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- LeetCode Database: Delete Duplicate Emails
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- LeetCode DB : Delete Duplicate Emails
Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...
- LeetCode - Delete Duplicate Emails
Discription:Write a SQL query to delete all duplicate email entries in a table named Person, keeping ...
随机推荐
- (python)每日代码||2024.1.29||斐波那契数列第i个数函数
def fib(n): a, b = 0, 1 for _ in range(n): a, b = b, a + b return a
- 洛谷P2415 集合求和(数学问题,使用集合子集求和公式)
可以知道对于一个有n个数据的集合,其子集个数有2^n个 至于证明可以这样理解,对于n个数据,其子集就是对数据进行组和,而对于每个位置上的数据,组合时仅有两种状态即有此数据或无此数据,也就是有两种可能, ...
- 如何修改11g RAC集群名称
背景:有一套11.2.0.4 RAC集群的环境,为了测试DG,直接复制了一套一模一样的环境,修改过IP之后,依然有问题,无法同时启动. 初步判断是因为在同一子网存在两个同名的集群(都是jystdrac ...
- 《ASP.NET Core 与 RESTful API 开发实战》-- (第6章)-- 读书笔记(下)
第 6 章 高级查询和日志 6.3 排序 RESTful API 在实现排序时应支持对集合资源的一个或多个属性进行排序 示例对 authors 资源按照其属性 Age 升序排序,再按 BirthPla ...
- Hive-安装和部署(Hive3.1.2)
(一)安装前提 (1) 安装JDK1.8及以上版本 (2) 已经安装MySQL,推荐5.7. (3) 已经安装Hadoop. JDK.MySQL.Hadoop的安装,本文不再介绍. (二)安装Hive ...
- JS Leetcode 198. 打家劫舍 题解分析,再次感受动态规划的魅力
壹 ❀ 引 本题来自LeetCode198. 打家劫舍,难度中等,也很有意思,是一道教小偷如何偷窃最大金额的题,题目描述如下: 你是一个专业的小偷,计划偷窃沿街的房屋.每间房内都藏有一定的现金,影响你 ...
- RocketMQ—RocketMQ消息重复消费问题
RocketMQ-RocketMQ消息重复消费问题 重复消费问题的描述 什么情况下会发生重复消费的问题: 生产者多次投递消息:如果生产者发送消息时,连接有延迟,MQ还没收到消息,生产者又发送了一次消息 ...
- 《深入理解Java虚拟机》(七) volatile 变量
目录 概述 一.内存模型 物理机内存模型 Java内存模型 Java内存模型中有如下的规定: 操作 二.Volatile变量 volatile修改变量后保证所有线程对其可见性 volatile禁止指令 ...
- centos上使用makefile编译sliver时 提示gcc 错误,cannot find -ldl cannot find -lpthread cannot find -lc
github.com/bishopfox/sliver/server /usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit ...
- django从配置文件中读取数据库信息
创建配置文件my.cnf [client] database=django_db user=root password=123456 host=127.0.0.1 port=3306 settings ...