表字段有id name cardid。查询出同一身份证号码有两条以上记录的身份证号码及其个数。
   谢谢各位大虾先~!

解决方案 »

  1.   

    select count(*),cartid from abc group by cartid having count(*)>2;
      

  2.   

    with temp as
    (
         select 1 a,2 b,3 c  from dual
         union all
         select 1,2,3 from dual
         union all 
         select 1,3,3 from dual
    union  all
         select 1,3,3 from dual
    union  all
         select 1,3,3 from dual
    union  all
         select 1,5,3 from dual
    union  all
         select 1,6,3 from dual
    union  all
         select 1,7,3 from dual)
    select a,b,c,rn from 
    (
           select a,b,c,count(1) rn from temp a  group by a ,b,c having count(1)>1
    ) b
    group by a,b,c
      

  3.   


    select cartid,count(cartid) from tb group by cartid  having count(cartid)>2
      

  4.   

    SELECT cardid,COUNT(1) FROM tablename GROUP BY cardid HAVING COUNT(1) > 1;应该是2条及两条以上吧
      

  5.   

    这个sql在数据量大的情况不够优化,较消耗资源
      

  6.   

    SELECT cardid,COUNT(1) FROM tablename GROUP BY cardid HAVING COUNT(1) > 1up