语句段
select top 50 branchdesc,total,amount,round(total/amount*100,2) as Done
from branchsale
order by total desc
修改语句为
select top 50 branchdesc,total,amount,cast(round(total/amount*100,2) as numeric(5,2))
from branchsale
order by total desc
报缺少as语句的错误!
请问各位老大, 查出的数据小数四舍五入保留2位,以上要报错,请问要用什么方式不写这个查询?谢谢!!!
------解决思路----------------------
你这样写法, float 转换为数据类型 numeric 时出现算术溢出错误
select top 50 branchdesc,total,amount,cast(round(total/amount*100,2) as numeric(18,2))
from branchsale
order by total desc
试下这种写法
------解决思路----------------------
修改后的语句,在语法上看没有问题,建议再确认一下"缺少as语句"错误的来源.
------解决思路----------------------
应该不会有错啊,要不,死马当活马医
select top 50 branchdesc,total,amount,cast(round(total/amount*100,2) as numeric(5,2))AS Done
from branchsale
order by total desc