当前位置:网站首页>Oracle deletes duplicate data, leaving only one
Oracle deletes duplicate data, leaving only one
2022-07-06 04:58:00 【Terence-Wang】
Query and delete duplicate records SQL sentence
1、 Look up redundant duplicate records in the table , Duplicate records are based on a single field (Id) To judge
select * from surface where Id in (select Id from surface group byId having count(Id) > 1)
2、 Delete redundant duplicate records in the table , Duplicate records are based on a single field (Id) To judge , There is only rowid Minimum record
DELETE from surface WHERE (id) IN ( SELECT id FROM surface GROUP BY id HAVING COUNT(id) > 1)
AND ROWID NOT IN (SELECT MIN(ROWID) FROM surface GROUP BY id HAVING COUNT(*) > 1);
3、 Look up redundant duplicate records in the table ( Multiple fields )
select * from surface a where (a.Id,a.seq) in(select Id,seq from surface group by Id,seq having count(*) > 1)
4、 Delete redundant duplicate records in the table ( Multiple fields ), There is only rowid Minimum record
delete from surface a where (a.Id,a.seq) in (select Id,seq from surface group by Id,seq having count(*) > 1)
and rowid not in (select min(rowid) from surface group by Id,seq having count(*)>1)
5、 Look up redundant duplicate records in the table ( Multiple fields ), It doesn't contain rowid Minimum record
select * from surface a where (a.Id,a.seq) in (select Id,seq from surface group by Id,seq having count(*) > 1)
and rowid not in (select min(rowid) from surface group by Id,seq having count(*)>1)
边栏推荐
- Three. JS learning - light and shadow (understanding)
- Scala function advanced
- Postman关联
- Building intelligent gray-scale data system from 0 to 1: Taking vivo game center as an example
- A blog to achieve embedded entry
- Three.js学习-光照和阴影(了解向)
- RTP GB28181 文件测试工具
- [buuctf.reverse] 159_ [watevrCTF 2019]Watshell
- 也算是学习中的小总结
- Extension of graph theory
猜你喜欢
随机推荐
Uva1592 Database
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
树莓派3.5寸屏幕白屏显示连接
[05-1, 05-02, 05-03] network protocol
Selection sort
Platformio create libopencm3 + FreeRTOS project
Extension of graph theory
2021robocom robot developer competition (Preliminary)
Three. JS learning - light and shadow (understanding)
Leetcode 186 Flip the word II in the string (2022.07.05)
Compilation et connexion de shader dans games202 - webgl (comprendre la direction)
集合详解之 Collection + 面试题
Hometown 20 years later (primary school exercises)
驱动开发——HelloWDM驱动
驱动开发——第一个HelloDDK
Supreme Court, judgment standard of divorce cases
[Chongqing Guangdong education] Suzhou University English film and Television Appreciation reference materials
Biscuits (examination version)
Application of Flody
[mathematical modeling] differential equation -- sustainable development of fishing industry