1
In my Mysql table I have a column called "weight". This column has the following values:
19.325
14.369
15.325
15.369
17.698
19.258
18.098
I simply need to accomplish the sum, but when I perform select sum(peso) from tabela
it returns me the value 119.44200000000001
instead of 119.442
.
Try to use the function
ROUND
to round up the values, for example:SELECT ROUND(SUM(peso), 3) AS peso FROM tabela;
– Valdeir Psr
Valdeir, you were fast is right. Perfect, solved my problem. Thank you very much.
– user116448
If you need exact numbers, the solution is to use exact decimal types, and no floating points. Round is a solution for sporadic and/or point situations.
– Bacco