[Info-ingres] precision

Paul White paul.white at shift7solutions.com.au
Thu Nov 15 13:51:01 UTC 2018


Yep worked a treat. Thanks Roy.

I was getting satisfaction from this but I think it has quite a bit more
overhead.

..having abs(sum(decimal(source_amount,20,2))) >= 0.01


select batch_no, count(*), sum(source_amount)
from testsum
group by batch_no
having abs(sum(source_amount)) >= float4(0.01)

+-------------+-------------+-----------+
|batch_no     |col2         |col3       |
+-------------+-------------+-----------+
|          123|           10|      0.010|
+-------------+-------------+-----------+
(1 row)


-----Original Message-----
From: Roy Hann [mailto:roy.hann at rationalcommerce.com] 
Sent: Thursday, 15 November 2018 11:37 PM
To: Paul White; 'Ingres and related product discussion forum'
Subject: Re: [Info-ingres] precision

Thursday, November 15, 2018, 1:04:27 PM, you wrote:

> Today I was surprised by a simple bit of Ingres maths.

[snip]

> select batch_no, count(*), sum(source_amount) from testsum
> group by batch_no
> having abs(sum(source_amount)) >= 0.01;

FLOATs are fuzzy. 0.01 above is implicitly DECIMAL. If you use

  ...having abs(sum(source_amount)) >= float4(0.01)

instead, it probably works as you hoped.

Roy Hann
Rational Commerce Ltd.
T +44 20 8691 2089
"Ingres development, tuning and training experts"




More information about the Info-ingres mailing list