当前位置:网站首页>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 .
边栏推荐
- Time module: acquisition and mutual transformation of timestamp, structured time and formatted time
- [二分查找简单题] LeetCode 35. 搜索插入位置,69. x 的平方根,367. 有效的完全平方数,441. 排列硬币
- [动态规划简单题] LeetCode 53. 最大子数组和
- 2513: Xiao Yong's academic score (common divisor problem)
- Go to export excel form
- Non global function of lua function
- Cloud development sleeping alarm clock wechat applet source code
- 数据湖(二十):Flink兼容Iceberg目前不足和Iceberg与Hudi对比
- cocos小游戏实战-05-NPC与角色攻击逻辑
- 数模1232
猜你喜欢

Boom 3D全新2022版音频增强应用程序App

Redis四大特殊数据类型的学习和理解

Inftnews | ggac and China Aerospace ases exclusively produce "China 2065 Collection Edition"

阿里云技术专家杨泽强:弹性计算云上可观测能力的构建

iNFTnews | “流量+体验”白衬e数字时装节引领数字时装新变迁

Compile and use protobuf Library in vs2019

be based on. NETCORE development blog project starblog - (16) some new functions (monitoring / statistics / configuration / initialization)

ArduinoUNO驱动RGB模块全彩效果示例

周全的照护 解析LYRIQ锐歌电池安全设计

Ten thousand words long text, take you to understand the kubernetes network model
随机推荐
Naive Bayes -- Document Classification
在线问题反馈模块实战(十五):实现在线更新反馈状态功能
Boom 3D全新2022版音频增强应用程序App
[paper]PointLaneNet论文浅析
Social wechat applet of fanzhihu forum community
易灵思T35 FPGA驱动LVDS显示屏
Arduino UNO +74hc164 water lamp example
Use the most primitive method to manually implement the common 20 array methods
Okaleido tiger logged into binance NFT on July 27, and has achieved good results in the first round
Favicon web page collection icon online production PHP website source code /ico image online generation / support multiple image format conversion
Kubernetes dashboard deployment application and access
数据湖(二十):Flink兼容Iceberg目前不足和Iceberg与Hudi对比
八皇后编程实现
一道数学题,让芯片巨头亏了5亿美金!
[dynamic planning medium] leetcode 198. looting 740. delete and get points
After two years of graduation, I switched to software testing and got 12k+, and my dream of not taking the postgraduate entrance examination with a monthly salary of more than 10000 was realized
Play a parallel multithreaded mcu-mc3172
智能指针shared_ptr、unique_ptr、weak_ptr
{“errcode“:44001,“errmsg“:“empty media data, hint: [1655962096234893527769663], from ip: 222.72.xxx.
Okaleido tiger is about to log in to binance NFT in the second round, which has aroused heated discussion in the community