On Thu, 25 Sep 2014 20:32:29 +0200
Mark Lawrence <[email protected]> wrote:
> I would have expected the group to work the same as the order, given
> that I think of the group as happening on the result set before any
> joins.
ORDER BY is different. It's not even *related* to GROUP BY.
To elaborate on Cory Nelson's answer, GROUP BY is part of the SELECT
processing, and ORDER BY is not. By analogy:
$ cat input | SELECT | ORDER BY > output
One way to understand it is that relational variables -- tables and
similar in SQL -- don't have order. You can manipulate them
independent of order, using as many operators (JOIN, WHERE, etc.) as you
please. Only when you're done can you ask the system, as a convenience
to yourself, to sort the results.
SQLite takes some liberties with that model. Depending on one's point
of view, supporting LIMIT and ORDER BY in a subquery is either a boon
or a wart. Regardless, SQL as defined by the standard treats ORDER BY
differently, for the above reasons.
--jkl
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users