(1) By MatiasG (vikingoarg2) on 2021-09-21 21:38:53 [link] [source]
Hi All, Can you help me to understand this?
this query does not working with some records that are equals:
CREATE TABLE CTRL_PAGOS_TRX AS SELECT a.ACCT_CODE, a.acct_id, '' ESTADO_CONTROL, cast(a.NEW_CREDIT as REAL) as NEW_CREDIT, CAST(ifnull(B.trx_amt,0) AS REAL) AS PPM FROM BILL_INVOICE a LEFT JOIN MOVIMIENTOS_TRX B ON B.acct_id=A.acct_id AND B.trans_type='PPM';
UPDATE CTRL_PAGOS_TRX SET ESTADO_CONTROL='OK' WHERE (NEW_CREDIT=PMA);
I try to set or cast fileds to TEXT or REAL but not match in some equal values:
NEW_CREDIT=PMA -1450.97=-1450.97 -1041.3=-1041.3 -2409.72=-2409.72
The issue you are having will probably become clearer once you compute and display the difference of your (allegedly) equal values. My wager is on the results not being zero as normal mathematics would require.
Should that be the case, and even if not, you should understand "What Every Computer Scientist Should Know About Floating-Point Arithmetic" if you are going to be using floating point values. Scheme has a better name for them, which is "inexact".