看不懂楼主的意思。如下可以算出 a的和除以(a+b)的和
Select (case when sum(a+b) = 0 then 0 else sum(a)/sum(a+b) end) from 表X

解决方案 »

  1.   

    什么意思?select a/(a+b) from x??还是:select count(a)/(count(a)+count(b)) from x??还是:select sum(a)/sum(a+b) from x
      

  2.   

    试试这个!
    select count(a)/(count(a)+count(b)+0.00) from x
      

  3.   

    Select (case when sum(isnull(a,0)+isnull(b,0)) = 0 then 0 else sum(isnull(a,0))/sum(isnull(a,0)+isnull(b,0)) end) from 表X
      

  4.   

    select sum(a)/sum(a+b+0.0) from x???
      

  5.   

    select sum(a)/sum(a+b+0.0) from x