I always work on the premise that "if I want data returned to my application in a specific order then code an ORDER BY clause"
If the dbms 'happens to' return data in the desired order then that is obviously good, but if that behaviour is not documented (and I don't know about SQLite) then without the ORDER BY you have to recognise that this behaviour may change. I typically work with a different dbms and the result set (almost gauranteed) will not be returned in 'group by' order. Cheers, Dave Ward Analytics Ltd - information in motion Tel: +44 (0) 118 9740191 Fax: +44 (0) 118 9740192 www: http://www.ward-analytics.com Registered office address: The Oriel, Sydenham Road, Guildford, Surrey, United Kingdom, GU1 3SR Registered company number: 3917021 Registered in England and Wales. -----Original Message----- From: sqlite-users [mailto:[email protected]] On Behalf Of Cecil Westerhof Sent: 24 August 2017 10:13 To: SQLite mailing list Subject: [sqlite] Do you really need an ORDER BY after a GROUP BY I always use an ORDER BY after a GROUP BY. For example: SELECT used , COUNT(used) FROM usedProverbs GROUP BY used ORDER BY used But when I leave the ORDER BY out in this case, the result is the same, but it looks like it is a bit faster. I probably keep using it, because in my case the performance is not important and if this works for SQLite3, but not for other databases, it is better to keep using it. -- Cecil Westerhof _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

