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)

Oracle学习笔记(1)——查询及删除重复数据的更多相关文章

  1. MySQL查询和删除重复数据

    删除表中重复记录,只保留一条: delete from 表名 where 字段ID in (select * from (select max(字段ID) from 表名 group by 重复的字段 ...

  2. 吴裕雄--天生自然python学习笔记:pandas模块删除 DataFrame 数据

    Pandas 通过 drop 函数删除 DataFrarne 数据,语法为: 例如,删除陈聪明(行标题)的成绩: import pandas as pd datas = [[65,92,78,83,7 ...

  3. Office365学习笔记—列表查询,删除条目,更新条目。

    1,基于Query语句的列表查询. function retrieveListItems(itemId) { var siteUrl=_spPageContextInfo.webServerRelat ...

  4. Oracle查询及删除重复数据

    1.查找表中多余的重复记录,重复记录是根据单个字段(Id)来判断 ) 2.删除表中多余的重复记录,重复记录是根据单个字段(Id)来判断,只留有rowid最小的记录 ) ); 3.查找表中多余的重复记录 ...

  5. Oracle 学习笔记 常用查询命令篇

    1.查询某个用户下有多少张表 有时候很有用  select count(*) from dba_tables t where t.owner='SCOTT';

  6. T-SQL技术收集——删除重复数据

    原文:T-SQL技术收集--删除重复数据 在工作和面试中,经常出现如何查询或者删除重复数据的问题,如果有主键,那还好办一点,如果没有主键,那就有点麻烦. 当一个表上没有辅助键时,如果使用SSMS界面来 ...

  7. Oracle 查询并删除重复记录的SQL语句

    查询及删除重复记录的SQL语句 1.查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断select * from peoplewhere peopleId in (select  ...

  8. oracle 查询及删除重复记录的SQL语句

    查询及删除重复记录的SQL语句 1.查找表中多余的重复记录,重复记录是根据单个字段(Id)来判断 select * from 表 where Id in (select Id from 表 group ...

  9. Oracle学习笔记三 SQL命令

    SQL简介 SQL 支持下列类别的命令: 1.数据定义语言(DDL) 2.数据操纵语言(DML) 3.事务控制语言(TCL) 4.数据控制语言(DCL)  

随机推荐

  1. hdu 5312 Sequence(数学推导+线性探查(两数相加版))

    Problem Description Today, Soda has learned a sequence whose n-th (n≥) item )+. Now he wants to know ...

  2. 最简单的XML转数组

    /** * 最简单的XML转数组 * @param string $xmlstring XML字符串 * @return array XML数组 */ function simplest_xml_to ...

  3. 利用jquery来隐藏input type="file"

    <li> <input type="text" name="token" value = "<?php ech$_SESSIO ...

  4. 纯html网页重定向与跳转

    javaScript 跳转 方法一: <script language="javascript">    window.location = "http:// ...

  5. PHP学习笔记三十【final】

    <?php //final不能去修饰属性(变量) //如果希望类不希望被继承就可以使用final关键字 final class Person() { public function sayHi( ...

  6. Linux命令:FREE

    FREE(1)                       Linux User's Manual                      FREE(1) NAME free - Display a ...

  7. Django 运行报错 ImportError: No module named 'PIL'

    importError: No module named pil WIN7 64位系统安装 Python PIL 首先通过easy_install安装 说找不到pil模块. 第二通过去官网找:http ...

  8. poj 3158kickdown

    我是来吐槽poj的!!! 第一次做poj,被题目中的输入输出格式打败了 ,醉了醉了 Description A research laboratory of a world-leading autom ...

  9. js的原型继承小结

    考虑:有一个想要复用的对象,并且想要创建的第二个对象需要从第一个对对象中获取其功能. 实现如下: //要继承的对象 var parent = { name:"Papa" }; // ...

  10. Ubuntu 安装 pecl_http

    由于开发环境需要用到pecl_http,根据网上找的教程一直没用按照成功,查看错误,pcre这里出错了,原来要安装这个libpcre3-dev,安装好这个就成功了,记下命令. $ sudo apt-g ...