a
b
b
c
c
c
查出结果
列  出现次数
a  1
b  2
c  3
怎么做

解决方案 »

  1.   

    补充,是出现次数最多的前10个
    列  出现次数
    c  3
    b  2
    a  1
      

  2.   

    select 列,count(*) from 表 group by 列
      

  3.   

    declare @t table(c varchar(4))
    insert into @t select 'a'
    insert into @t select 'b'
    insert into @t select 'b'
    insert into @t select 'c'
    insert into @t select 'c'
    insert into @t select 'c'
    insert into @t select 'd'
    insert into @t select 'd'
    insert into @t select 'd'
    insert into @t select 'd'select top 10 c,count(*) 出现次数 from @t group by c order by 出现次数 desc
      

  4.   

    select 列,出现次数=count(1) from 表 group by 列
      

  5.   


    ----------
    select 列,出现次数=count(1) from 表 group by 列  order by 出现次数 desc
      

  6.   

    select colname,count(*) from table group by colname
      

  7.   

    select 列,出现次数=count(1) from 表
     group by 列
      order by 出现次数 desc