在sql语句中计算精度的问题,头疼了好几天,就是没解决
sqlserver吧
全部回复
仅看楼主
level 2
阿布通
楼主
select * from table_3;
select fname, CAST(lipeinum/insurenum as decimal(9,4))as expr from table_3
语句是这样写的,为什么它的值一直都是0.0000呢,怎么精确到确切的4位小数呢。有什么方法
2017年09月25日 03点09分
1
level 9
nice想杀人
我的回复怎么没了
2017年09月26日 01点09分
3
阿布通
2楼失踪了嘛
2017年09月26日 11点09分
nice想杀人
回复
遗忘vcr
:是啊
2017年09月26日 12点09分
level 3
zerowinner
你应该先把两个字段转再做除法
2017年10月10日 13点10分
4
level 4
杨剑109
楼主字段应该是整型的,做除法获取到的是整型。先转换为小数在做除法。
select * from table_3;
select fname, CAST(cast(lipeinum as float)/insurenum as decimal(9,4))as expr from table_3
2017年10月11日 09点10分
5
杨剑109
还有做除法需要预防分母为0的情况。
2017年10月11日 09点10分
1