I'm getting a bad result when adding up a column on DB2. The data is a string and I'm passing it through float() and then into sum().
The set looks like this:
AMOUNT
--------
0.100
0.250
0.500
0.050
0.150
0.150
0.150
0.600
0.600
0.150
And when I add it I get the wrong result like so:
1> select
2> sum(float(amount)) as sum_amount
3> from
4> TABLE
5> where
6> [CONDITIONS]
13> go
SUM_AMOUNT
------------------
2.6999999999999997
Any idea why this is happening? Suggestions to fix it?