比如:张三  高血压 
      赵六  高血压
      小张  高血压
      李四  冠心病
      小李  冠心病
      王五  糖尿病
      小三  慢支
我要的结果:疾病排位是高血压(3)、冠心病(2)、糖尿病(1)

解决方案 »

  1.   

    select * from tablename order by 疾病排名
      

  2.   

    select top 3 * from tablename order by 疾病排名
      

  3.   

    select top 3 bing, count(*) from table1
    group by bing
    order by count(*) desc
      

  4.   

    哦。。原来要的是汇总之后的结果。。
    select top 3 病人名, count(*) from table1
    group by 病人名
    order by count(*) desc
      

  5.   

    上面的错了
    哦。。原来要的是汇总之后的结果。。
    select top 3 疾病名, count(*) from table1
    group by 疾病名
    order by count(*) desc
      

  6.   

    小虫给出的答案是正确的
    count(*)也可以写成count(bing)
    select top 3 bing, count(bing) from table1
    group by bing
    order by count(bing) desc
      

  7.   

    补充:
       完全同意 postren(小虫) 答案,其实Count()内的内容是可以随便写的,只要是常量,字段或*,我一般都是用1代替如count(1),只要简单就喜欢!