这是数据表结构
a字段 
44
33      
44
bb
ee
ee
ee我想根据出现次数最多的进行排序,怎么写语名啊

解决方案 »

  1.   

    select a from t1 group by a order by count(1)
      

  2.   

    declare @tb table(a nvarchar(100))
    insert into @tb select '44'
    union all select '33'      
    union all select '44'
    union all select 'bb'
    union all select 'ee'
    union all select 'ee'
    union all select 'ee'
    select * from @tbselect a,count(a) 数量 from @tb group by a order by count(a)desc
      

  3.   

    create table test(a char(20))
    insert into  testselect '44' union all
    select '33' union all
    select '44' union all
    select 'bb' union all
    select 'ee' union all
    select 'ee' union all
    select 'ee' select a,count(a)b  
    from test
    group by a
    order by b desc
      

  4.   

    declare @tb table(a varchar(10))
    insert @tb 
      select '44' union all
      select '33' union all      
      select '44' union all
      select 'bb' union all
      select 'ee' union all
      select 'ee' union all
      select 'ee'
    select a,count(a) num 
      from @tb
     group by a
     order by num desc
    /*
    a        num
    -----------------
    ee 3
    44 2
    bb 1
    33 1
    */