你應該寫在存儲過程里面.
如果你要把那些比率為0的也顯示出來,應再加一個表,放ID和问题类型
declare @total integer
select @total=count(probleid) from probletable
select count(probleid)/@total from probletable group by probleid

解决方案 »

  1.   

    如果只用一个SQL语句的话就是这样了
    select convert(money,count(*))/(select count(*) from table6),
    probletype 
    from table6 
    group by probletype 
    order by count(*) desc不过效率很低的 最好通过存储过程 先把select count(*) from table6求出来
    不用每次计算了
    别忘了convert()转化一下数据类型 不然的话都变成整数0了
      

  2.   

    谢谢各位但是还有个问题
    如果probletype 包含这样的数据“问题A,问题B,问题C”
    好想不能直接GROUP BY 把
      

  3.   

    如果probleType中用这样几条纪录
    groupId    probleType
    1          问题A
    2          问题B
    3          问题A,问题B,问题C
    4          问题A,问题C
    直接group by那么就会得出一上有4个组,但我要的是三个组阿
    A出现3次,B出现2次,C出现2次的结果。
    请问怎么写