+ For backwards compatibility with the SQL92 version of the standard,
+ a <replaceable>sort_expression</> can instead be the name or number
+ of an output column, as in
+<programlisting>
+SELECT a + b AS sum, c FROM table1 ORDER BY sum;
+SELECT a, max(b) FROM table1 GROUP BY a ORDER BY 1;
+</programlisting>
+ both of which sort by the first output column. Note that an output
+ column name has to stand alone, it's not allowed as part of an expression
+ — for example, this is <emphasis>not</> correct:
+<programlisting>
+SELECT a + b AS sum, c FROM table1 ORDER BY sum + c; -- wrong
+</programlisting>
+ This restriction is made to reduce ambiguity. There is still
+ ambiguity if an <literal>ORDER BY</> item is a simple name that
+ could match either an output column name or a column from the table
+ expression. The output column is used in such cases. This would
+ only cause confusion if you use <literal>AS</> to rename an output
+ column to match some other table column's name.
+ </para>
+
+ <para>
+ <literal>ORDER BY</> can be applied to the result of a
+ <literal>UNION</>, <literal>INTERSECT</>, or <literal>EXCEPT</>
+ combination, but in this case it is only permitted to sort by
+ output column names or numbers, not by expressions.