Keith Brilliant! Thank you.
> Correlated (outer) columns are not permitted in the ORDER BY clause At least I've learnt a new term [1]. Reading the documentation again [2], I think a change to the paragraph below would make this clearer: 3. Otherwise, if the ORDER BY expression is any other expression, it is evaluated and the returned value used to order the output rows. If the SELECT statement is a simple SELECT, then an ORDER BY may contain any arbitrary expressions. However, if the SELECT is a compound SELECT, then ORDER BY expressions that are not aliases to output columns must be exactly the same as an expression used as an output column. Maybe add a sentence: "If the SELECT is a correlated inner subquery then the ORDER BY expression may not include columns from the outer query." I'm also not sure if it would help to drop the word "any" from "any arbitrary expressions"? I'm afraid I didn't get very far trying to look up a standard. I appreciate your help! Thanks again. Kind Regards Keith Maxwell [1] https://en.wikipedia.org/wiki/Correlated_subquery [2] https://www.sqlite.org/lang_select.html#order-by _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users