How to prevent to store also the 0 in decimal?


How to prevent to store also the 0 in decimal?



I need to save the avg of a value, that in this case corresponds to the average attendance of a venue, and for this, I created a new field called avg which has this structure: decimal(10,3).


avg


avg


decimal(10,3)



Now if I store a value like this: 2671, the field will contain: 2.671 that's correct, but if I need to store only 800 I'll get: 800.000 that's, of course, is a different number…


800


800.000



So how can I store the correct decimal value? In this case should be only 800, not 800.000.



Also, how can I adjust the bad values stored in the database without repeat all the insert?



Thanks.





800 is 800.000. What happens to 2671 to make it 2.671 ?
– Alex K.
Jun 29 at 16:17






If you need to distinguish between "800" and "800.000" then you need to store the value as a string. Arithmetically, the two values are equivalent.
– Gordon Linoff
Jun 29 at 16:18





The fractional part is zero so has no significance, 800 == 800.000 == true
– Alex K.
Jun 29 at 16:20





What is the difference between eight hundred and eight hundred point 000 ? or you think 800.000 is 8 hundred thousand? If it bugs your for the display, just cut it using the functions of the language you implement it in.
– Nic3500
Jun 29 at 16:20



eight hundred


eight hundred point 000


8 hundred thousand





Okay, I understood what is the problem thank you guys
– Charanoglu
Jun 29 at 17:30




1 Answer
1



The decimal point is irrelevant, you can trim the decimal point using another function.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Opening a url is failing in Swift

Export result set on Dbeaver to CSV