比如
A     B
1     1
1     2
2     3
2     3      //和上面有重复了
2     4
3     5
3     5
3     5     //有3个重复了
3     6
我要找出有重复的列出来
A     B
2     3
3     5
3     5

解决方案 »

  1.   

    你看看这个博客,读懂了应该可以解决你的问题。
    http://blog.csdn.net/yangsh0722/article/details/8021246
      

  2.   

    select a,b from tb group by a,b having count(*)>1
      

  3.   

    if object_id('[tb]') is not null drop table [tb]
    go
    create table [tb]([A] int,[B] int)
    insert [tb]
    select 1,1 union all
    select 1,2 union all
    select 2,3 union all
    select 2,3 union all
    select 2,4 union all
    select 3,5 union all
    select 3,5 union all
    select 3,5 union all
    select 3,6
    go;with cte as
    (select rn=row_number() over(order by getdate()),* from tb)select a.a,a.b
    from cte a
    join (select min(rn) as rn,a,b from cte group by a,b) b
    on a.a=b.a and a.b=b.b and a.rn!=b.rn/**
    a           b
    ----------- -----------
    2           3
    3           5
    3           5(3 行受影响)
    **/