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

Commita7abae4

Browse files
committed
Fix subsection ordering (DISTINCT should be described before LIMIT).
1 parent852b4ae commita7abae4

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

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

Lines changed: 40 additions & 40 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.79 2005/01/0403:58:16 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.80 2005/01/0408:59:45 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -695,6 +695,45 @@ SELECT name FROM distributors ORDER BY code;
695695
was initialized.
696696
</para>
697697
</refsect2>
698+
699+
<refsect2 id="sql-distinct">
700+
<title id="sql-distinct-title"><literal>DISTINCT</literal> Clause</title>
701+
702+
<para>
703+
If <literal>DISTINCT</> is specified, all duplicate rows are
704+
removed from the result set (one row is kept from each group of
705+
duplicates). <literal>ALL</> specifies the opposite: all rows are
706+
kept; that is the default.
707+
</para>
708+
709+
<para>
710+
<literal>DISTINCT ON ( <replaceable
711+
class="parameter">expression</replaceable> [, ...] )</literal>
712+
keeps only the first row of each set of rows where the given
713+
expressions evaluate to equal. The <literal>DISTINCT ON</literal>
714+
expressions are interpreted using the same rules as for
715+
<literal>ORDER BY</> (see above). Note that the <quote>first
716+
row</quote> of each set is unpredictable unless <literal>ORDER
717+
BY</> is used to ensure that the desired row appears first. For
718+
example,
719+
<programlisting>
720+
SELECT DISTINCT ON (location) location, time, report
721+
FROM weather_reports
722+
ORDER BY location, time DESC;
723+
</programlisting>
724+
retrieves the most recent weather report for each location. But
725+
if we had not used <literal>ORDER BY</> to force descending order
726+
of time values for each location, we'd have gotten a report from
727+
an unpredictable time for each location.
728+
</para>
729+
730+
<para>
731+
The <literal>DISTINCT ON</> expression(s) must match the leftmost
732+
<literal>ORDER BY</> expression(s). The <literal>ORDER BY</> clause
733+
will normally contain additional expression(s) that determine the
734+
desired precedence of rows within each <literal>DISTINCT ON</> group.
735+
</para>
736+
</refsect2>
698737

699738
<refsect2 id="SQL-LIMIT">
700739
<title id="sql-limit-title"><literal>LIMIT</literal> Clause</title>
@@ -739,45 +778,6 @@ OFFSET <replaceable class="parameter">start</replaceable>
739778
</para>
740779
</refsect2>
741780

742-
<refsect2 id="sql-distinct">
743-
<title id="sql-distinct-title"><literal>DISTINCT</literal> Clause</title>
744-
745-
<para>
746-
If <literal>DISTINCT</> is specified, all duplicate rows are
747-
removed from the result set (one row is kept from each group of
748-
duplicates). <literal>ALL</> specifies the opposite: all rows are
749-
kept; that is the default.
750-
</para>
751-
752-
<para>
753-
<literal>DISTINCT ON ( <replaceable
754-
class="parameter">expression</replaceable> [, ...] )</literal>
755-
keeps only the first row of each set of rows where the given
756-
expressions evaluate to equal. The <literal>DISTINCT ON</literal>
757-
expressions are interpreted using the same rules as for
758-
<literal>ORDER BY</> (see above). Note that the <quote>first
759-
row</quote> of each set is unpredictable unless <literal>ORDER
760-
BY</> is used to ensure that the desired row appears first. For
761-
example,
762-
<programlisting>
763-
SELECT DISTINCT ON (location) location, time, report
764-
FROM weather_reports
765-
ORDER BY location, time DESC;
766-
</programlisting>
767-
retrieves the most recent weather report for each location. But
768-
if we had not used <literal>ORDER BY</> to force descending order
769-
of time values for each location, we'd have gotten a report from
770-
an unpredictable time for each location.
771-
</para>
772-
773-
<para>
774-
The <literal>DISTINCT ON</> expression(s) must match the leftmost
775-
<literal>ORDER BY</> expression(s). The <literal>ORDER BY</> clause
776-
will normally contain additional expression(s) that determine the
777-
desired precedence of rows within each <literal>DISTINCT ON</> group.
778-
</para>
779-
</refsect2>
780-
781781
<refsect2 id="SQL-FOR-UPDATE">
782782
<title id="sql-for-update-title"><literal>FOR UPDATE</literal> Clause</title>
783783

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp