Oracle学习笔记(1)——查询及删除重复数据
2024-10-12 04:48:38
1、查找表中多余的重复记录(根据单个字段studentid)
select * from table_name where studentid in (select studentid from table_name group by studentid having count(studentid) > 1)
2、查找表中多余的重复记录(根据多个字段studentid,name...)
select * from table_name a where (a.studentid,a.name) in(select studentid,name from 表 group by studentid,name having count(*) > 1)
3、删除表中多余的重复记录(根据单个字段studentid)
delete from table_name a where a.studentid in( select studentid from table_name group by studentid having count(studentid) > 1)
4、删除表中多余的重复记录(根据多个字段studentid,name...)
delete from table_name a where (a.studentid,a.name) in( select studentid,name from table_name group by studentid,name having count(*) > 1)
5、删除表中多余的重复记录(根据单个字段studentid),只保留id最小的记录
delete from table_name a where a.name in( select name from table_name group by id having count(name) > 1)
and a.id not in (select min(id) from table_name group by name having count(*) > 1)
6、删除表中多余的重复记录(根据多个字段name,studentid...),只保留id最小的记录
delete from table_name a where (a.name,a.studentid) in (select name,studentid from table_name group by name,studentid having count(*) > 1)
and a.id not in (select min(id) from table_name group by name,studentid having count(*)>1)
最新文章
- Mybatis的基本操作案列增加以及源码的分析(二)
- EF架构~CodeFirst生产环境的Migrations
- AStar算法的学习
- Jasper(物联网网络支撑平台公司)的技术为什么这么牛逼?
- select()函数 timval问题
- 监听器初始化Job、JobTracker相应TaskTracker心跳、调度器分配task源码级分析
- GNU Radio 之 rtl-sdr
- 搜索 基础 AC 2014-01-14 15:53 170人阅读 评论(0) 收藏
- 将数字映射到字母上 .xml
- WIN7 下 Qt Creator 安装 QWT
- Bigcommerce:intershop编程经验总结
- 判断textview是否被截断
- canvas绘制自定义的曲线,以椭圆为例,通俗易懂,童叟无欺
- linux shell脚本学习xargs命令使用详解
- Mockito教程
- HDU1284--完全背包
- 【转1】Appium 1.6.3 在Xcode 8, iOS 10.2(模拟器)测试环境搭建 经验总结
- chattr文件锁
- 【新特性】JDK11
- 封装个 Android 的高斯模糊组件
热门文章
- poj 2385 Apple Catching(dp)
- C++中,访问字符串的三种方法
- [POJ 3734] Blocks (矩阵高速幂、组合数学)
- HDU 1085 Holding Bin-Laden Captive! (母函数)
- EffectiveC#5--始终提供ToString()
- Android 使用monkey自动测试
- Spring mvc中@RequestMapping 6个基本用法整理
- poj1623 Squadtrees
- Reading source code
- Windows I/O模型之一:Select模型