On 11 Oct 2016, at 1:44pm, Eric Minbiole <[email protected]> wrote:
>> Your problem is that although SQL accepts the clauses written in the order >> you wrote them in, the LIMIT clause is processed before the ORDER BY clause. > > Is that really true? I had always thought that the ORDER BY was processed > first, though I admit I don't see anything authoritative either way. I didn't know. Which is why I wrote about what was happening rather than what a specification said should happen. The order in which these clauses are listed in the SQLite documentation suggests that ORDER BY should be performed /before/ LIMIT. I did find this: <http://dev.mysql.com/doc/refman/5.7/en/limit-optimization.html> "If you combine LIMIT row_count with ORDER BY, MySQL ends the sorting as soon as it has found the first row_count rows of the sorted result" Note the word 'sorted'. This agrees with what I wrote above, in that it suggest that in MySQL ORDER BY must be processed first. I'm happy to see that Keith says that the behaviour noted by Tobias was a bug and has been fixed. I also note that a test for this combination of clauses appears in the test suite, so the bug shouldn't happen again. Simon. _______________________________________________ sqlite-users mailing list [email protected] http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

