I have a query that will get the sum of some columns in my postgres database.
def total = Funds.executeQuery("SELECT SUM(a.FundA), SUM(a.FundB), SUM(a.FundC), SUM(a.FundA+a.FundB+a.FundC) FROM Funds a")
Given that FundA
, FundB
and FundC
is defined as double.
Values: (Sample Only)
FundA = 233.343
= 3.234
= 324.23423
FundB = 32423.4234
= 43.434
= 234.234
FundC = 234.2342
= 343.4345
= 23423.3434
Query Result:
[560.81123, 32701.0914, 24001.0121, 57262.914730000004]
The sum of FundA
, FundB
and FundC
is correct but the overall total is not trailing zero's with four at the end is not quite right.
Actual Result: 57262.914730000004
Expected Result: 57262.91473
How can I get the exact over all sum of the 3 columns? Without rounding off. Thank you