oracle表内查重

oracle表内查重

问:oracle查询表中是否有重复数据
  1. 答:如果两列数据重复的话,可以通过count方法,找出计算条数大于1的,那么表示此条数据重复:
    sql: select district(*) from products having count(*)>1;
    备注:实际上两列重复的话,都是针对某个字段比较有意。
    sql:select name,count(*) from usertable group by name having count(*)>1;
    以上语句就是查询出名字重复的所有用户,并计算重复的次数。
  2. 答:SELECT (SELECT COUNT(*) FROM 表名)-(SELECT COUNT(*) FROM (SELECT DISTINCT * FROM 表名)) 重复记录数 FROM DUAL;
  3. 答:查单个字段:
    Sql代码
    SELECT TEST_NAME,COUNT(*) FROM T_TEST GROUP BY TEST_NAME HAVING COUNT(*) >1
    查组合字段:
    Sql代码
    SELECT TEST_NAME1,TEST_NAME2,COUNT(*) FROM T_TEST GROUP BY TEST_NAME1,TEST_NAME2 HAVING COUNT(*) > 1
  4. 答:1、查找单个字段:
    select 字段名,count(*) from table group by 字段名 having count(*) > 1
    2、查找组合字段:
    SELECT TEST_NAME1,TEST_NAME2,COUNT(*) FROM table GROUP BY TEST_NAME1,TEST_NAME2 HAVING COUNT(*) > 1
问:如何查询oracle数据库表中的重复记录
  1. 答:用group by ... having...
    比如查询,a,b,c,d四列组合是否有重复的
    select a,b,c,d,count(*)
    from tablename
    group by a,b,c,d
    having count(*) > 1
问:oracle/mysql表数据查重
  1. 答:select user_name,count(*) as count from user_table group by user_name having count>1;
问:Oracle中对表中每个字段都做查重该如何写
  1. 答:列出所有栏位:栏位1,栏位2,栏位3......
    select 栏位1,栏位2,栏位3,count(*)
    from user_table
    group by 栏位1,栏位2,栏位3
    having count(*)>1;
  2. 答:使用distinct去重
    select distinct col1, col2, col3 from tab;
问:Oracle多字段表 统计完全重复记录
  1. 答:SELECT COUNT(1) AS AMOUNT, A.A1, A.A2, FROM TABLE_A A GROUP BY A.A1, A.A2 having
    count(*) >= 2 ;
oracle表内查重
下载Doc文档

猜你喜欢