I have found a bug in the way sqlite treats ORDER BY clauses. to reproduce the bug, run this script against an empty database (memory db would do):
=========================================== CREATE TABLE Eidh ( ekey VARCHAR(12) NOT NULL, perigrafh VARCHAR(30) NOT NULL, PRIMARY KEY(ekey)); INSERT INTO Eidh VALUES('0001','bla'); CREATE TABLE KinApo ( ekey VARCHAR(12) NOT NULL , date DATE, polhths INTEGER); INSERT INTO KinApo VALUES('0001',38353,40); INSERT INTO KinApo VALUES('0001',38353,30); INSERT INTO KinApo VALUES('0001',38353,20); select kinapo.ekey, kinapo.polhths from eidh inner join kinapo on eidh.ekey=kinapo.ekey order by eidh.ekey, kinapo.polhths ============================================== versin 3.2.2 of sqlite gives the following result set, which is unordered: 0001 40 0001 30 0001 20 also, EXPLAIN shows that no sorting is taking place. This is a SERIOUS malfunction! can you pls verify this in other environments (I am using dll 3.2.2, locally compiled), and do something about it.