On Mon, 15 Feb 2016 08:56:35 +0100
Clemens Ladisch <clemens at ladisch.de> wrote:

> I don't know why correlated subqueries cannot use values from the
> outer query in the ORDER BY or LIMIT clauses; 

ORDER BY is not part of SELECT!  It's not a relational operator.
Per the SQL standard -- ORDER BY cannot appear in a subquery. It can
appear in only one place: as a kind of post-processor that determines
the order in which the rows are delivered to the client.  

I suspect that's why Postgres ORDER BY doesn't recognize column names
in the enclosing scope.  If the day ever comes when SQLite can remove
language features, internal ORDER BY (and LIMIT) would be at the top of
my list, along with double-quotes for strings. 

--jkl

Reply via email to