SQLite Forum

ORDER BY not working for a specific DB/table
Login
Ok, I found the issue from the values in the dumped database


      BEGIN TRANSACTION;
      CREATE TABLE latiSaltxi (westCCod, lati10, longi);
      INSERT INTO latiSaltxi VALUES(408,41.199999999999995735,129.72757172350807764);
      INSERT INTO latiSaltxi VALUES(408,41.200000000000002843,129.72079500000000962);
      INSERT INTO latiSaltxi VALUES(840,41.200000000000002843,-73.970000999999996338);
      INSERT INTO latiSaltxi VALUES(840,41.200000000000002843,-73.964172000000004913);
      COMMIT;

      SELECT * FROM latisaltxi WHERE lati10 >= 41 ORDER BY lati10, longi;

      408|41.2|129.727571723508
      840|41.2|-73.970001
      840|41.2|-73.964172
      408|41.2|129.720795

      SELECT * FROM latisaltxi WHERE lati10 >= 41.2 ORDER BY lati10, longi;      

      840|41.2|-73.970001
      840|41.2|-73.964172
      408|41.2|129.720795

Actually it was not that the result was correctly ordered but it simply eliminated the weird C real

This bizarre decimals come only in a dump but not in all sqlite queries that can be done, that confuses a lot.

Where do they come from? I only use either

         ROUND(xx, 1)   from sqlite
         or 
         Math.round(xx*10)/10.  from javascript (Rhino)

I would say from sqlite's ROUND, it looks like a typical and nasty C/C++ arithmetic issues.