表A中有字段B 其中有重复值(内容) 请计算出重复值(内容)是什么? 有几个? 

解决方案 »

  1.   

    select B,count(*)
    from A
    group by B
    having count(*)>1
      

  2.   

    select B,count(*)
    from A
    group by B
    having count(*)>1
      

  3.   

    select B,
           count(*) [个数]
    from A
    group by B
      

  4.   

    select B,count(*) 
    from A 
    group by b 
    having count(b)>1
      

  5.   

    select B,count(*)
    from A
    group by B
    having count(*)>1
      

  6.   

    select count(1),b from
    from a
    where exists(select * from a z where z.b = a.b)
    group by b这样也可以.
    嘿嘿,面试的时候多写几种方法应该更好吧?
      

  7.   

    来晚了只有顶!
    select B,count(*)
    from A
    group by B
    having count(*)>1