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. VB6各类源码开源 - 开源研究系列文章

    今天把以前下载整理的关于VB6的一些代码进行了开源,覆盖了多个分类内容,需要的朋友请下载: VB6源码.part1 https://download.csdn.net/download/lzhdim/ ...

  2. 论文精读:用于少样本图像识别的语义提示(Semantic Prompt for Few-Shot Image Recognition)

    原论文于2023.11.6撤稿,原因:缺乏合法的授权,详见此处 Abstract 在小样本学习中(Few-shot Learning, FSL)中,有通过利用额外的语义信息,如类名的文本Embeddi ...

  3. Delphi dbgrideh颜色设置

    DBGridEh中分行分列.单元格的颜色设置(1)分行不同颜色设置:在DBGridEh1DrawColumnCell中写: if ADOQuery1.RecNo mod 2=0 then begin ...

  4. Python-open函数-读写文件

    一.open 函数语法 open() 函数的作用是打开一个文件,并返回一个 file对象(即文件对象). open 是一个动作,可以理解为我们打开文档的点击动作. file 对象是一个实物,可以理解为 ...

  5. NVME(学习笔记_杂谈)

    NVME 协议中一些概念的理解: 1.Namespace :可以将Namespace 理解为一片Logic Block的区域,一个Controller可以支持多个Namespace,每个Namespa ...

  6. Linux进程的创建与销毁

    Linux操作系统是一种多任务.多用户的操作系统,这意味着它可以同时运行多个进程,每个进程都可以执行不同的任务. 在本文中,我们将介绍如何在Linux系统中创建和销毁进程. 进程的创建 在Linux系 ...

  7. javascript 对http的get请求参数编码encodeURIComponent、encodeURI 和Java 解码

    JavaScript 代码encode functionfindNE(){ var nd = document.getElementById("NE").value; nd = e ...

  8. java 注解结合 spring aop 自动输出日志新增拦截器与过滤器

    auto-log auto-log 是一款为 java 设计的自动日志监控框架. 前面已经写过了两篇: java 注解结合 spring aop 实现自动输出日志 java 注解结合 spring a ...

  9. Detours 的使用

    Detours 是一个用于在 ARM, ARM64, X86, X64 和 IA64 机器上拦截二进制函数的库. Detours 最常用来拦截应用程序中的 win32 api 调用,比如添加调试工具. ...

  10. nosql几种热门数据库的优缺点及应用场景

    MongoDB.ElasticSearch.Redis.HBase这四种热门数据库的优缺点及应用场景 https://www.cnblogs.com/chong-zuo3322/p/12869059. ...