accident表不重复的:
 select section,seqno from  accident group by section,seqno having count(1) = 1human表不重复的:
 select section,seqno from  human group by section,seqno having count(1) = 1如果是查重复的就只要把having count(1) = 1改成having count(1) > 1  就好了

解决方案 »

  1.   

    human表里section,seqno的组合应该是可以重复的吧。如果是这样的话,上面的第二条语句还要加一个sno的:
    select section,seqno,sno from  human group by section,seqno,sno having count(1) = 1
      

  2.   

    对C2,要先把human里重复的数据删除了才能加上,C3应该没什么问题的。
      

  3.   

    谢谢楼上先
    1、对于accident表,select distinct section,seqno from  accident能不能实现你说的效果?
    2、我是想查不重复的记录的“条数”,不知道改怎么查
      

  4.   

    1、对于accident表,select distinct section,seqno from  accident能不能实现你说的效果?
        
        此句查询的是accident表中section,seqno 组合去除重复后的结果集,就是如果section,seqno 的组合有重复的,那么在查询出来的结果集中只会显示一次。如:
    section    seqno 
    ----  ---
    A         B
    A         C
    A         C
    A         D那么查询的结果将会是:
    section    seqno 
    ----  ---
    A         B
    A         C
    A         D
      

  5.   

    2、我是想查不重复的记录的“条数”,不知道改怎么查     select count(1) from
            ( select section,seqno 
               from  accident 
              group by section,seqno 
             having count(1) = 1
            ) A;     select count(1) from
           ( select section,seqno,sno 
              from  human 
             group by section,seqno,sno
             having count(1) = 1
           ) A;
      

  6.   

    现在human表的主键c2已经被删除了。
    如果我导出现在有重复数据的数据为文本文件,再删除里面的数据,应该就可以加上c2的主键了吧,加上之后再导入,是不是重复的数据就被删除了(重复的数据只剩下一条记录)。
      

  7.   

    我是想查不重复的记录的“条数”,不知道改怎么查?
    select count(*)
    from accident 
    group by section , seqno
    having count(*) =1
      

  8.   

    现在human表的主键c2已经被删除了。
    如果我导出现在有重复数据的数据为文本文件,再删除里面的数据,应该就可以加上c2的主键了吧,加上之后再导入,是不是重复的数据就被删除了(重复的数据只剩下一条记录)。
    ====================================
    可以的,但如果你并不需要手工决定重复的数据中需要保留哪条数据的话,可以有更简单的方法删除重复的数据:
      Delete from human
      where rowid not in (select max(rowid) //保留rowid最大的
                            from  human 
                           group by section,seqno,sno
                           having count(1) > 1
                          ) 
           and rowid in
              (select A.rowid
               from human A join (select section,seqno,sno 
                                    from  human 
                                  group by section,seqno,sno
                                  having count(1) > 1                               
                                  ) B
                        on A.section=B.section and A.seqno=B.seqno and A.son=B.sno
               )
      

  9.   

    没有rowid 这列,怎么办?
      

  10.   

    rowid是oracle自带的,记录的是一条记录的物理地址
      

  11.   

    你可以认为每一个表都有一个oracle自带的rowid字段
      

  12.   

    问题基本解决,谢谢hevin大哥!