Sum (SUM) of a column with irregular formatting

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 do the sum, but when I run select sum(peso) from tabela it returns me the value 119.44200000000001 instead of 119.442 .

    
asked by anonymous 18.06.2018 / 15:58

1 answer

1

Man, this depends a lot, did you use float or double?  But you can in the create use the decimal, example   Create table_name ( // here I am passing two houses after the comma

decimal weight (3, 2) not null, );

    
18.06.2018 / 16:18