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. 【Linux】虚拟机太卡咋办?用云服务器Xshell配置Vmware虚拟机【技能篇】

    [Linux]用云服务器Xshell配置Vmware虚拟机[技能篇] 强烈建议本篇收藏后再食用~ 文章目录 Xshell下载 配置Vmware 尾声 平时我们使用虚拟机,可能最烦人的问题就是卡顿了.今 ...

  2. CF383C Propagating tree

    题目链接 题目 见链接. 题解 知识点:DFS序,树状数组. 我们需要对子树的不同奇偶层加减,用dfn序可以解决子树问题,但是并不能直接分奇偶. 一种比较麻烦的思路是,将dfn序分成两个序列,一个是偶 ...

  3. NC51100 A Simple Problem with Integers

    题目链接 题目 题目描述 You have N integers, \(A_1, A_2, ... , A_N\) .You need to deal with two kinds of operat ...

  4. IPFS Gateway Selector IPFS下载网关选择工具

    简介 用IPFS作文件分享可以覆盖很多场景, 现在IPFS网关也相当多了, 但是因为国内网络的状况, 不同网关在不同网络运营商的表现差别很大, 导致你提供的下载链接在对方那里可能速度很慢, 甚至无法访 ...

  5. Shadow DOM的理解

    Shadow DOM的理解 Shadow DOM是HTML的一个规范,其允许在文档document渲染时插入一颗DOM元素子树,但是这棵子树不在主DOM树中,Shadow DOM如果按照英文翻译的话可 ...

  6. 一次nginx返回422状态码的经历

    故事背景 后端使用Docker Compose部署一个代码片段管理应用:snibox,某天因为云服务卡死重启之后再次访问时,登录或退出都返回422状态码. 界面提示如下: 不过奇怪的是:直接通过IP+ ...

  7. 自定义组件WebComponents加HTML模板template元素及shadowDOM影子DOM及定义一些事件

    自定义组件WebComponents加HTML模板template元素及shadowDOM影子DOM及定义一些事件 Web Components 自定义组件,可以自定义一个类似于div的元素,里面的事 ...

  8. 教你如何判断Java代码中异步操作是否完成

    本文分享自华为云社区<java代码实现异步返回结果如何判断异步执行完成>,作者: 皮牙子抓饭. 在许多应用程序中,我们经常使用异步操作来提高性能和响应度.在Java中,我们可以使用多线程或 ...

  9. HttpURLConnection使用分析

    在项目中遇到各种版本的httpClient,所以想了解一下httpClient的实现 首先查看的是JDK1.1中自带的HttpURLConnection,看一下最初的设计是怎么样的 代码分析 使用Ht ...

  10. 红胖子(红模仿)的博文大全:开发技术集合大版本更新v4.0.0

    <红胖子(红模仿)的博文大全:开发技术集合(包含Qt实用技术.树莓派.三维.OpenCV.OpenGL.ffmpeg.OSG.单片机.软硬结合等等)持续更新中...>大版本更新,更新后版本 ...