有两个表的结构是一样的 包含的字段是续号,身份证号,姓名分别统计表A中身份证号重复的数据
统计结果为 续号  身份证号  姓名,重复次数   (只取一个人的就可以)统计表A和表B中身份证号重复的数据
统计结果为  序号 身份证号 姓名 重复次数(取表A中的人,如果该人是在表B中重复则取表B的数据)

解决方案 »

  1.   

    select * from A where rowid=(select min(rowid) from A aa where A.身份证号=aa.身份证号)
      

  2.   

    select * from (select * from A where rowid=(select min(rowid) from A aa where A.身份证号=aa.身份证号)) aa,(select 身份证号,count(*) as 重复次数 from A group by 身份证号) bb where aa.身份证号 =b.身份证号
      

  3.   

    分别统计表A中身份证号重复的数据
    统计结果为 续号  身份证号  姓名,重复次数   (只取一个人的就可以)
    select 续号 ,身份证号, 姓名,重复次数
    from
    (
    select 续号 ,身份证号, 姓名, 
           count(身份证号) over (order by 身份证号)  重复次数,
           row_number() over (partition by 身份证号 order by 续号,姓名) rowid
    from a
    )
    where 重复次数 = rowid 
      and rowid > 1
      

  4.   

    select 序号,身份证号,姓名,count(身份证号)over(order by 身份证号) 重复次数 
      from b 
    where exits(
                  select 序号,身份证号,姓名
                         ,count(身份证号)over(order by 身份证号) 重复次数)
                    from a
               )
      

  5.   

    分别统计表A中身份证号重复的数据
    统计结果为 续号  身份证号  姓名,重复次数   (只取一个人的就可以)
    ------------------------------->
    select t.*
      from (select 序号,身份证号,姓名,count(*)over(order by 身份证号) 重复次数 
            from 表A ) t
    group by t.重复次数>=2
      

  6.   

    group by t.重复次数>=2
    -------->修正:
    where t.重复次数>=2
      

  7.   

    统计表A和表B中身份证号重复的数据
    统计结果为  序号 身份证号 姓名 重复次数(取表A中的人,如果该人是在表B中重复则取表B的数据)
    ------------------------------->
    select t1.*
      from (select 序号,身份证号,姓名,count(*)over(order by 身份证号) 重复次数 
            from 表B ) t1
    where t1.重复次数>=2unionselect t2.*
    from (select 序号,身份证号,姓名,count(*)over(order by 身份证号) 重复次数 
          from 表A ) t2
    where  t2.重复次数>=2
    and  t2.身份证号  not in
           (
            select t3.身份证号
            from (select 序号,身份证号,姓名,count(*)over(order by 身份证号) 重复次数 
                  from 表B ) t3
            where t3.重复次数>=2
            ) 
      

  8.   

    count(*)over(order by 身份证号)并不是取重复次数呀
      

  9.   

    分别统计表A中身份证号重复的数据
    统计结果为 续号  身份证号  姓名,重复次数   (只取一个人的就可以)
    select 续号 ,身份证号, 姓名,重复次数
    from
    (
    select 续号 ,身份证号, 姓名, 
           count(*)  重复次数,
           row_number() over (partition by 身份证号 order by 续号,姓名) rowid
    from a
    )
    where 重复次数 = 2
      

  10.   

    select 续号 ,a1.身份证号, 姓名,b.重复次数 from 
    (select 续号,身份证号, 姓名,        
           row_number() over (partition by 身份证号order by 续号,姓名) rank
    from a) a1, (select 身份证号,
           count(*) 重复次数
    from a group by 身份证号) b
    where a1.rank=2 and a1.身份证号=b.身份证号
      

  11.   

    to:code2code(代码代码) 
    >count(*)over(order by 身份证号)并不是取重复次数呀
    对,不是取的重复数,启的别名不好,控制重复的在外层,判断这个别名子段>=2.
      

  12.   

    小声的问一下,好像用Group By 加Having也可以吧??
    两个表统计,用Union all ,再group by 加Having