vendredi 4 décembre 2015

SQLITE floating number precission issue

I have a table with the folowing:

Name  Number Pct
A     12.1     Null
A     24.5     Null
A      5.6     Null
B     10.4     Null
B     11.1     Null
etc.

I am trying to populate the Pct column and for that I use:

UPDATE Table SET
Pct= Number/ (SELECT SUM(b.Number) FROM Table b WHERE name = b.name GROUP by b.name);

On my results the sum of all A Pcts is 1. But when I sum all Bs I get something like 1.0000015. If I copy paste the data to Excel, sum all Numbers by name and divide I get 1 for everything.

Is it possible that SQLite is loosing precision somewhere?

Aucun commentaire:

Enregistrer un commentaire