select b,count(1)as c from 表 group by b

解决方案 »

  1.   

    select B,C=count(*)
    from 表
    group by b
    having count(*)>1
      

  2.   

    1: select b,count(*) as c from 表 group by b
       having count(*) > 12: select top 1 * from 
    (select b,count(*) as c from 表 group by b
       having count(*) > 1
    ) tmp order by c
      

  3.   

    --测试--测试数据
    create table 表(a int,b int)
    insert 表 select 1,3
    union all select 2,3
    union all select 3,4
    union all select 4,4
    union all select 5,4
    union all select 6,5
    union all select 7,5
    union all select 8,3
    union all select 9,3
    go--查询
    select B,C=count(*)
    from 表
    group by b
    having count(*)>1
    go--删除测试
    drop table 表/*--测试结果
    B           C           
    ----------- ----------- 
    3           4
    4           3
    5           2(所影响的行数为 3 行)
    --*/
      

  4.   

    select b,c from (selelct b,count(1) as c from 表 group by b) where c=(select min(c) from (selelct b,count(1) as c from 表 group by b))
      

  5.   

    1.
    select b,convert(varchar,count(b))+'次' as c from table1 group by b having count(b)>1
    2.
    select top 1 * from (select b,count(b)as c from table1 group by b having count(b)>1 order by count(b))
      

  6.   

    感动啊,头回到这版问问题,回帖率这样高,速度如此之快!并且在 txlicenhe(马可) 的答案里找到了解决方法,谢谢大家。