From: Tom Lane Date: Tue, 9 Jan 2007 16:59:20 +0000 (+0000) Subject: Marginal tweaks in the documentation for ORDER BY; in particular point X-Git-Tag: REL8_3_BETA1~1562 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e0bf9041ebb5cf80e83c48fd06214c5d6e22c17;p=postgresql Marginal tweaks in the documentation for ORDER BY; in particular point out the common error that ORDER BY x, y DESC does not mean the same as ORDER BY x DESC, y DESC. --- diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml index 5c48ae1d62..c427303db3 100644 --- a/doc/src/sgml/queries.sgml +++ b/doc/src/sgml/queries.sgml @@ -1,4 +1,4 @@ - + Queries @@ -1262,6 +1262,13 @@ SELECT a, b FROM table1 ORDER BY a + b, c; DESC order, and NULLS LAST otherwise. + + Note that the ordering options are considered independently for each + sort column. For example ORDER BY x, y DESC means + ORDER BY x ASC, y DESC, which is not the same as + ORDER BY x DESC, y DESC. + + For backwards compatibility with the SQL92 version of the standard, a sort_expression can instead be the name or number diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml index 0af1fbb07a..f77b805118 100644 --- a/doc/src/sgml/ref/select.sgml +++ b/doc/src/sgml/ref/select.sgml @@ -1,5 +1,5 @@ @@ -644,13 +644,6 @@ HAVING condition ORDER BY expression [ ASC | DESC | USING operator ] [ NULLS { FIRST | LAST } ] [, ...] - expression can be the - name or ordinal number of an output column - (SELECT list item), or it can be an arbitrary - expression formed from input-column values. - - - The ORDER BY clause causes the result rows to be sorted according to the specified expression(s). If two rows are equal according to the leftmost expression, they are compared @@ -659,6 +652,13 @@ ORDER BY expression [ ASC | DESC | an implementation-dependent order. + + Each expression can be the + name or ordinal number of an output column + (SELECT list item), or it can be an arbitrary + expression formed from input-column values. + + The ordinal number refers to the ordinal (left-to-right) position of the result column. This feature makes it possible to define an @@ -717,6 +717,12 @@ SELECT name FROM distributors ORDER BY code; on whether the operator is a less-than or greater-than operator. + + Note that ordering options apply only to the expression they follow; + for example ORDER BY x, y DESC does not mean + the same thing as ORDER BY x DESC, y DESC. + + Character-string data is sorted according to the locale-specific collation order that was established when the database cluster