SELECT detail, count, cstr(cint((count/iif((select sum(count) from diaoc_m where voteid=2)=0,1,(select sum(count) from diaoc_m where voteid=2)))*10000)/100)+'%' AS precount FROM diaoc_m WHERE voteid=2
...全文
1026打赏收藏
一个在acsess中执行得sql语句无法在mssql中执行 询问解决方案
SELECT detail, count, cstr(cint((count/iif((select sum(count) from diaoc_m where voteid=2)=0,1,(select sum(count) from diaoc_m where voteid=2)))*10000)/100)+'%' AS precount FROM diaoc_m WHERE voteid=2
SELECT detail,count,cast(cast((count/case when (select sum(count) from diaoc_m where voteid=2)=0 then 1 else (select sum(count) from diaoc_m where voteid=2))*10000 as int)/100 as varchar)+'%' AS precount FROM diaoc_m WHERE voteid=2