I read the documentation @ http://www.sqlite.org/lang_select.html, but could not understand if LIMIT works before or after the ORDER BY clause.
So if my SQL is:
SELECT date(event_time) as ct, jobName
FROM events
WHERE jobName = "MY_TEST_JOB"
ORDER BY event_time DESC
LIMIT 10;
Will the result set include the most recent 10 events, or will the limit apply before the sorting operation?
LIMITis applied after theORDER BY, so you will get the first 10 records sorted byevent_time(in ascending order, so the 10 “oldest” events).If you’re trying to get the 10 newest events, you would just change your
ORDER BYto: