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的更多相关文章

  1. leetcode【sql】 Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  2. [SQL]196. Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  3. [LeetCode] Delete Duplicate Emails 删除重复邮箱

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  4. LeetCode——Delete Duplicate Emails(巧用mysql临时表)

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  5. 【SQL】182. Duplicate Emails

    Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Emai ...

  6. SQL Server Delete Duplicate Rows

    There can be two types of duplication of rows in a table 1. Entire row getting duplicated because th ...

  7. [SQL]LeetCode196. 删除重复的电子邮箱 | Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  8. LeetCode Database: Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  9. LeetCode DB : Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  10. LeetCode - Delete Duplicate Emails

    Discription:Write a SQL query to delete all duplicate email entries in a table named Person, keeping ...

随机推荐

  1. 让 JuiceFS 帮你做好「异地备份」

    家住北京西二旗的小张是一家互联网金融公司的运维工程师,金融行业的数据可是很值钱的,任何的损坏和丢失都不能容忍. 为此,小张选了北京品质最高的机房,买了品质最好的硬件,做了全面的数据备份容灾策略: 每 ...

  2. .NET Core开发实战(第34课:MediatR:轻松实现命令查询职责分离模式(CQRS))--学习笔记(下)

    34 | MediatR:轻松实现命令查询职责分离模式(CQRS) 实际上我们在定义我的查询的时候,也可以这样定义,例如我们定义一个 MyOrderQuery,把订单的所有名称都输出出去 namesp ...

  3. react router component与render有什么区别?提升渲染性能,记一个react router component 误用导致请求死循环的有趣bug

    壹 ❀ 引 下午前端大佬突然私聊我,说发现了一个很有趣的bug,问我有没有兴趣,因为我平时会记录一些自认为有意思的问题,所以毫不犹豫就答应了,问题表现如下,当我们系统进入到某个页面下时,接口居然无止境 ...

  4. JS Leetcode 220. 存在重复元素 III 题解分析,暴力解法与桶排序

    壹 ❀ 引 今天的题目来自LeetCode 220. 存在重复元素 III,难度中等,题目描述如下: 给你一个整数数组 nums 和两个整数 k 和 t .请你判断是否存在 两个不同下标 i 和 j, ...

  5. NC24141 [USACO 2011 Dec G]Grass Planting

    题目链接 题目 题目描述 Farmer John has N barren pastures (2 <= N <= 100,000) connected by N-1 bidirectio ...

  6. P2P通讯方式

    概述 实现p2p通讯我们提供两种方式,这两种方式分别是通过客户端直接互通和p2p映射: 无论哪一种,首先设备两端都得部署好fastnat客户端,NAT类型不能是对称类型NAT(Symmetric),否 ...

  7. 使用virtualenv新建django项目

    # 安装virtualenv pip install virtualenv # 创建虚拟环境 virtualenv venv # 进入虚拟环境 venv\Scripts\activate # 安装dj ...

  8. EXPLAIN命令

    EXPLAIN命令   除了以SELECT开头的查询语句,其余的DELETE.INSERT.REPLACE以及UPDATE语句前边都可以加上EXPLAIN这个词儿,用来查看这些语句的执行计划   Ty ...

  9. 【Android逆向】Frida 无脑暴力破解看雪test2.apk

    1. 安装apk到手机 adb install -t test2.apk apk下载位置: https://www.kanxue.com/work-task_read-800625.htm 2. 题目 ...

  10. 学习go语言编程之常量

    什么在常量 在Golang中,常量是指在编译期就已知且不可改变的值. 字面常量 在程序中硬编码的常量值被称为字面常量,如: -12 // 整数类型常量 3.1415926 // 浮点类型常量 3.2+ ...