如何避免在sql中舍入小数 [英] how to avoid decimal being rounded off in sql

查看:91
本文介绍了如何避免在sql中舍入小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将一个像'121.93'这样的值插入到十进制类型的字段中

,但问题是它会被舍入到像'122'这样的值,我不想发生这种情况。



你知道如何解决这个问题吗?

i am inserting a value like '121.93' into a field which of type decimal
but the problem is that it gets rounded off to a value like '122' which I dont want happening.

do you know how to fix this?

推荐答案

也许你没有正确配置列。您必须指定小数点右侧的位数,如下所示:



十进制(10,2) - 十位数,右边两位小数点。



编辑============



我好奇。如果这是答案(它看起来像是这样),你为什么把它投票给4?
Maybe you didn't correct configure the column. You have to specify the number of places to the right of the decimal, like this:

decimal(10,2) - ten digits, with two to the right of the decimal point.

EDIT ============

I'm curious. If this was "the" answer (which it looks like it was), why did you vote it a 4?


这篇关于如何避免在sql中舍入小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆