sqlite> create table test (Qty DECIMAL(10,2));
    sqlite> insert into test values(1059.79);
    sqlite> insert into test values(-1050);
    sqlite> insert into test values(83.58);
    sqlite> insert into test values(130.51);
    sqlite> insert into test values(-5);
    sqlite> insert into test values(-136.68);
    sqlite> insert into test values(-2.6);
    sqlite> insert into test values(-75);
    sqlite> insert into test values(-4.6);
    sqlite> select sum(Qty) FROM TEST;
    -6.21724893790088e-14
Given that I explicitly specified DECIMAL(10,2) as the field type, why is the sum not 0?
SQLite does not have a DECIMAL type. Math is performed using 64-bit floating point values.
See SQLite3 data types
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With