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 ...
随机推荐
- Exadata存储节点的CPU限制成功了没?
上篇随笔谈到刷1/8 rack时,日志显示存储节点已经成功限制CPU的,可如果使用mpstat命令看貌似还是64 CPU,难道实际没有成功吗? [root@dbm08celadm03 ~]# mpst ...
- Navicat 15 for MySQL 破解【我亲测可用】
1.去官网下载正版 https://www.navicat.com.cn/ 2.破解下载:https://files-cdn.cnblogs.com/files/del88/NavicatKeygen ...
- .NET Core开发实战(第7课:用Autofac增强容器能力)--学习笔记(下)
07 | 用Autofac增强容器能力:引入面向切面编程(AOP)的能力 如何获取没有命名的服务呢? // Autofac 容器获取实例的方式是一组 Resolve 方法 var service = ...
- 【译】发布 .NET Aspire 预览版 2(二)
原文 | Damian Edwards 翻译 | 郑子铭 组件更新 组件包现在有单独的图标 大多数 Aspire 组件的 NuGet 包现在都具有代表性图标,以便在 NuGet 包管理器对话框中更轻松 ...
- 动态获取input内容文本(排除候选拼音文本) - js事件
要想通过事件实时获取文本框文本,一开始是想到下面的方法,但实际效果都存在一定的缺点. 通过change/blur事件获取 change事件只有在选中点击或者失焦的时候,才能够触发. blur事件则是只 ...
- CF1823D Unique Palindromes
题目链接 题解 知识点:构造. 首先反证法容易证明一个结论:每次增加一个字符,本质不同的回文子串至多增加一个. 那么无解的条件就是,\(c_i - c_{i-1} > x_i -x_{i-1}\ ...
- 【leetcode】合并 k 个有序链表,我给了面试官这 5 种解法
开胃菜 在进入本节的正题之前,我们先来看一道开胃菜. 题目 21. 合并两个有序链表 将两个升序链表合并为一个新的 升序 链表并返回.新链表是通过拼接给定的两个链表的所有节点组成的. 示例: 输入:1 ...
- Java并发编程实例--15.在同步代码块中使用条件
并发编程中有个经典问题: 生产消费者问题. 我们有一个数据缓冲区,一个或多个生产者往其中存入对象,另外一个或多个消费者从中取走. 因此,该数据缓冲区是一个共享数据结构,我们需要对其添加读取同步机制,但 ...
- 系统环境变量中 HTTPS_PROXY 的误区
前段时间在测试一个连麦 demo,demo 简要说可以在内网环境中运行时,输入频道号就可以模拟连麦 但是在加入连麦时,一直返回错误 -2 EOF,询问得知,该错误的解释信息是"Service ...
- python列表操作的大O效率