用户的一个表因为疏忽没设主码,现在想查查这段时间有没有重复的数据.jh,rq两个字段应该是主码

解决方案 »

  1.   

    select * from table group by jh,rq having count(1)>1
      

  2.   

    select * from ( 
      select jh,rq,count(1)over(partition by jh,rq) cnt from table
    ) a where cnt>1;
      

  3.   


    select * from (
      select jh,rq,row_number()over(partition by jh,rq order by rq) as cnt from t2
    ) a where cnt>1;
      

  4.   


    select *
    from   table1 a
    where  exists (select 1 from table where jh = a.jh and rq = a.rq and rowid <> a.rowid)
      

  5.   

    select jh,rq,count(*) from table_name group by jh,rq having count(*) > 1;
      

  6.   

    用户的一个表因为疏忽没设主码,现在想查查这段时间有没有重复的数据.jh,rq两个字段应该是主码select jh,rq from tb group by jh,rq having count(*) > 1
      

  7.   

    select jh,rq  from table where rowid!=(
           select max(rowid) from table t
           where table.jh=t.jh
           and   table.rq=t.rq);
      

  8.   

    统计重复的select jh,rq count(*) from table group by jh,rq having count(1)>1
    显示重复记录select by jh table a,(select jh,rq count(*) from table group by jh,rq having count(1)>1) b where b.jh=b.jh and a.rq=b.rg group by jh,rg
      

  9.   

    select id count(id) from table group by id;