select City,Count(City) as 人数 
from UserInfo 
Group by City order by 人数 Desc

解决方案 »

  1.   

    我本来是
    select City,Count(City) as 人数 
    from UserInfo 
    Group by City order 
    但加了order by 人数 Desc
    后就出现如下错误:
     No value given for one or more required parameters
      

  2.   

    是不是Access不支持阿,或者order不支持那个统计变量阿?
      

  3.   

    select x.*
    from (select City,Count(City) as 人数 
           from UserInfo 
          Group by City)x
    order by x.人数
      

  4.   

    select City,Count(City) as 人数 
    from UserInfo 
    Group by City order by 2 Desc
      

  5.   


    --测试数据
    create table UserInfo (userid int,username varchar(10),city varchar(10))
    insert UserInfo select '1','Rain','广州'
    union all select '2','Clever','广州'
    union all select '3','Wind','珠海'
    union all select '4','Snow','珠海'
    union all select '5','Cloud','广州'
    go--查询
    select City,Count(City) as 人数 
    from UserInfo 
    Group by City order by 人数 Desc
    go--删除测试
    drop table UserInfo/*--结果City       人数          
    ---------- ----------- 
    广州         3
    珠海         2(所影响的行数为 2 行)
    --*/
      

  6.   

    select City,Count(City) as 人数 
    from UserInfo 
    Group by City order 
    但加了order by 人数 Desc这样不行
    select City,Count(City) as 人数 
    from UserInfo 
    Group by City order by 2 Desc
    谢谢热心的兄弟们!小弟祝各位工作顺利,生活开心!