Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1e0bf90

Browse files
committed
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 asORDER BY x DESC, y DESC.
1 parent69db009 commit1e0bf90

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

‎doc/src/sgml/queries.sgml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/queries.sgml,v 1.40 2007/01/0902:14:10 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/queries.sgml,v 1.41 2007/01/0916:59:20 tgl Exp $ -->
22

33
<chapter id="queries">
44
<title>Queries</title>
@@ -1262,6 +1262,13 @@ SELECT a, b FROM table1 ORDER BY a + b, c;
12621262
<literal>DESC</> order, and <literal>NULLS LAST</> otherwise.
12631263
</para>
12641264

1265+
<para>
1266+
Note that the ordering options are considered independently for each
1267+
sort column. For example <literal>ORDER BY x, y DESC</> means
1268+
<literal>ORDER BY x ASC, y DESC</>, which is not the same as
1269+
<literal>ORDER BY x DESC, y DESC</>.
1270+
</para>
1271+
12651272
<para>
12661273
For backwards compatibility with the SQL92 version of the standard,
12671274
a <replaceable>sort_expression</> can instead be the name or number

‎doc/src/sgml/ref/select.sgml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.95 2007/01/0902:14:10 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.96 2007/01/0916:59:20 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -644,13 +644,6 @@ HAVING <replaceable class="parameter">condition</replaceable>
644644
<synopsis>
645645
ORDER BY <replaceable class="parameter">expression</replaceable> [ ASC | DESC | USING <replaceable class="parameter">operator</replaceable> ] [ NULLS { FIRST | LAST } ] [, ...]
646646
</synopsis>
647-
<replaceable class="parameter">expression</replaceable> can be the
648-
name or ordinal number of an output column
649-
(<command>SELECT</command> list item), or it can be an arbitrary
650-
expression formed from input-column values.
651-
</para>
652-
653-
<para>
654647
The <literal>ORDER BY</literal> clause causes the result rows to
655648
be sorted according to the specified expression(s). If two rows are
656649
equal according to the leftmost expression, they are compared
@@ -659,6 +652,13 @@ ORDER BY <replaceable class="parameter">expression</replaceable> [ ASC | DESC |
659652
an implementation-dependent order.
660653
</para>
661654

655+
<para>
656+
Each <replaceable class="parameter">expression</replaceable> can be the
657+
name or ordinal number of an output column
658+
(<command>SELECT</command> list item), or it can be an arbitrary
659+
expression formed from input-column values.
660+
</para>
661+
662662
<para>
663663
The ordinal number refers to the ordinal (left-to-right) position
664664
of the result column. This feature makes it possible to define an
@@ -717,6 +717,12 @@ SELECT name FROM distributors ORDER BY code;
717717
on whether the operator is a less-than or greater-than operator.
718718
</para>
719719

720+
<para>
721+
Note that ordering options apply only to the expression they follow;
722+
for example <literal>ORDER BY x, y DESC</> does not mean
723+
the same thing as <literal>ORDER BY x DESC, y DESC</>.
724+
</para>
725+
720726
<para>
721727
Character-string data is sorted according to the locale-specific
722728
collation order that was established when the database cluster

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp