当前位置:网站首页>196. Delete duplicate email addresses
196. Delete duplicate email addresses
2022-07-27 03:13:00 【only-qi】
Problem description :
SQL framework
surface : Person
+-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | email | varchar | +-------------+---------+ id Is the primary key column of the table . Each row of the table contains an email . Email will not contain uppercase letters .
Write a SQL Delete statements Come on Delete All duplicate emails , Keep only one id The smallest and only email .
With In any order Return result table . ( Be careful : Just write a delete statement , The remaining results will be queried automatically )
The query result format is as follows .
Example :
Example 1:
Input : Person surface : +----+------------------+ | id | email | +----+------------------+ | 1 | [email protected] | | 2 | [email protected] | | 3 | [email protected] | +----+------------------+ Output : +----+------------------+ | id | email | +----+------------------+ | 1 | [email protected] | | 2 | [email protected] | +----+------------------+ explain : [email protected] Repeat twice . We keep the smallest Id = 1.
Pass times 153,609 Submit the number 226,963
On sql, Take it to run :
Create table statement :
CREATE TABLE `person` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`email` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;DELETE
FROM
`person`
WHERE
id IN (
SELECT * from ( SELECT max( id ) AS id FROM `person` GROUP BY email HAVING count( * ) > 1 ) as a
)
SELECT * from person Running results :

I want to brush it 300 Algorithm questions , The first 110 Avenue .
边栏推荐
- 毕业2年转行软件测试获得12K+,不考研月薪过万的梦想实现了
- 身家破亿!86版「红孩儿」拒绝出道成学霸,已是中科院博士,名下52家公司
- [SQL简单题] LeetCode 627. 变更性别
- 手动从0搭建ABP框架-ABP官方完整解决方案和手动搭建简化解决方案实践
- Compile and use protobuf Library in vs2019
- Ansible series: do not collect host information gather_ facts: False
- Cloud development sleeping alarm clock wechat applet source code
- 2649: segment calculation
- 杀毒软件 clamav 的安装和使用
- 用最原始的方法纯手工实现常见的 20 个数组方法
猜你喜欢
随机推荐
数据湖(二十):Flink兼容Iceberg目前不足和Iceberg与Hudi对比
Analysis of [paper] pointlanenet papers
全网最全的软件测试基础知识整理(新手入门必学)
2513: 小勇学分数(公约数问题)
Knowledge points of test questions related to software testing
[paper]PointLaneNet论文浅析
Shell (38): SSH port forwarding
win10/win11无损扩大C盘空间,跨盘合并C、E盘
[SQL simple question] leetcode 627. change gender
Plato Farm全新玩法,套利ePLATO稳获超高收益
八皇后编程实现
数模1232
ansible系列之:不收集主机信息 gather_facts: False
Worth more than 100 million! The 86 version of "red boy" refuses to be a Daocheng Xueba. He is already a doctor of the Chinese Academy of Sciences and has 52 companies under his name
The EXE compiled by QT is started with administrator privileges
ZJCTF_login
Bulk copy baby upload prompt garbled, how to solve?
How big is the bandwidth of the Tiktok server for hundreds of millions of people to brush at the same time?
万字长文,带你搞懂 Kubernetes 网络模型
QT编译出来的exe以管理员权限启动








