当前位置:网站首页>SQL: query duplicate data and delete duplicate data
SQL: query duplicate data and delete duplicate data
2022-04-23 20:24:00 【First code】
1. Single column
select * from test
where name in (select name from test group by name having count
(name) > 1
select * from [ Department information summary ]
where Effective or not = 1 and [ Department name ] in (select [ Department name ] from [ Department information summary ] where Effective or not =1 group by [ Department name ] having count
([ Department name ]) > 1)
and Where in (select Where from[ Department information summary ] group by Where having count
( Where ) > 1)
2 Multiple columns
SELECT a.* FROM test a,(
SELECT name,code
FROM test
GROUP BY name,code
HAVING COUNT(1)>1
) AS b
WHERE a.name=b.name AND a.code=b.code
3 Delete duplicate data
Take deleting duplicate ID cards as an example
delete from Test
where ID number in( select ID number from Test group by ID number having count( ID number ) > 1) and
TK not in(select max(TK) from Test group by ID number having count( ID number ) > 1 )
Query duplicate ID card
select ID number ,count(*) from Test group by ID number having count(*) > 1
版权声明
本文为[First code]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210551267930.html
边栏推荐
- Why does ES6 need to introduce map when JS already has object type
- Investigate why close is required after sqlsession is used in mybatties
- The construction and use of Fortress machine and springboard machine jumpserver are detailed in pictures and texts
- Cadence Orcad Capture 批量更改元件封装功能介绍图文教程及视频演示
- Tensorflow 2 basic operation dictionary
- Wave field Dao new species end up, how does usdd break the situation and stabilize the currency market?
- LeetCode 542、01 矩阵
- Building the tide, building the foundation and winning the future -- the successful holding of zdns Partner Conference
- After route link navigation, the sub page does not display the navigation style problem
- SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
猜你喜欢
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
Servlet learning notes
Plato farm is one of the four largest online IEOS in metauniverse, and the transaction on the chain is quite high
Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
Customize timeline component styles
Tensorflow 2 basic operation dictionary
On BIM data redundancy theory
After route link navigation, the sub page does not display the navigation style problem
LeetCode 542、01 矩阵
SQL Server Connectors By Thread Pool | DTSQLServerTP 插件使用说明
随机推荐
【PTA】L1-002 打印沙漏
Linux64Bit下安装MySQL5.6-不能修改root密码
Intersection calculation of straight line and plane in PCL point cloud processing (53)
考研英语唐叔的语法课笔记
PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)
Numpy - creation of data type and array
PCL点云处理之基于PCA的几何形状特征计算(五十二)
Scripy tutorial - (2) write a simple crawler
Markdown < a > tag new page open link
R language uses the preprocess function of caret package for data preprocessing: BoxCox transform all data columns (convert non normal distribution data columns to normal distribution data and can not
[talkative cloud native] load balancing - the passenger flow of small restaurants has increased
Unity 模型整体更改材质
2022 - Data Warehouse - [time dimension table] - year, week and holiday
波场DAO新物种下场,USDD如何破局稳定币市场?
Operation of numpy array
Confusion about thread blocking after calling the read () method of wrapper flow
SIGIR'22 "Microsoft" CTR estimation: using context information to promote feature representation learning
Redis的安装(CentOS7命令行安装)
Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
Numpy mathematical function & logical function