@@ -1742,13 +1742,6 @@ UNBOUNDED FOLLOWING
17421742 <para>
17431743 Here, <replaceable>expression</replaceable> represents any value
17441744 expression that does not itself contain window function calls.
1745- <literal>PARTITION BY</> behaves like a <literal>GROUP
1746- BY</> clause by grouping rows into partitions, except its
1747- expressions are always just expressions and cannot be output-column
1748- names or numbers. <literal>ORDER BY</> behaves similar to a
1749- query-level <literal>ORDER BY</> clause, except it controls the
1750- order rows are supplied to the aggregate function within the window
1751- frame, and with the same expression restrictions.
17521745 </para>
17531746
17541747 <para>
@@ -1766,18 +1759,49 @@ UNBOUNDED FOLLOWING
17661759 </para>
17671760
17681761 <para>
1769- In <literal>RANGE</> mode, <literal>CURRENT ROW</> starts with
1770- the current row's first peer that <literal>ORDER BY</>
1771- considers equivalent, and ends with its last equivalent peer. In
1772- <literal>ROWS</> mode, <literal>CURRENT ROW</> simply starts and ends
1773- with the current row.
1762+ The <literal>PARTITION BY</> option groups the rows of the query into
1763+ <firstterm>partitions</>, which are processed separately by the window
1764+ function. <literal>PARTITION BY</> works similarly to a query-level
1765+ <literal>GROUP BY</> clause, except that its expressions are always just
1766+ expressions and cannot be output-column names or numbers.
1767+ Without <literal>PARTITION BY</>, all rows produced by the query are
1768+ treated as a single partition.
1769+ The <literal>ORDER BY</> option determines the order in which the rows
1770+ of a partition are processed by the window function. It works similarly
1771+ to a query-level <literal>ORDER BY</> clause, but likewise cannot use
1772+ output-column names or numbers. Without <literal>ORDER BY</>, rows are
1773+ processed in an unspecified order.
1774+ </para>
1775+
1776+ <para>
1777+ The <replaceable class="parameter">frame_clause</replaceable> specifies
1778+ the set of rows constituting the <firstterm>window frame</>, which is a
1779+ subset of the current partition, for those window functions that act on
1780+ the frame instead of the whole partition. The frame can be specified in
1781+ either <literal>RANGE</> or <literal>ROWS</> mode; in either case, it
1782+ runs from the <replaceable>frame_start</> to the
1783+ <replaceable>frame_end</>. If <replaceable>frame_end</> is omitted,
1784+ it defaults to <literal>CURRENT ROW</>.
1785+ </para>
1786+
1787+ <para>
1788+ A <replaceable>frame_start</> of <literal>UNBOUNDED PRECEDING</> means
1789+ that the frame starts with the first row of the partition, and similarly
1790+ a <replaceable>frame_end</> of <literal>UNBOUNDED FOLLOWING</> means
1791+ that the frame ends with the last row of the partition.
1792+ </para>
1793+
1794+ <para>
1795+ In <literal>RANGE</> mode, a <replaceable>frame_start</> of
1796+ <literal>CURRENT ROW</> means the frame starts with the current row's
1797+ first <firstterm>peer</> row (a row that <literal>ORDER BY</> considers
1798+ equivalent to the current row), while a <replaceable>frame_end</> of
1799+ <literal>CURRENT ROW</> means the frame ends with the last equivalent
1800+ peer. In <literal>ROWS</> mode, <literal>CURRENT ROW</> simply means
1801+ the current row.
17741802 </para>
17751803
17761804 <para>
1777- <literal>UNBOUNDED PRECEDING</> means that the frame
1778- starts with the first row of the partition, and similarly
1779- <literal>UNBOUNDED FOLLOWING</> means that the frame ends with the last
1780- row of the partition.
17811805 The <replaceable>value</> <literal>PRECEDING</> and
17821806 <replaceable>value</> <literal>FOLLOWING</> cases are currently only
17831807 allowed in <literal>ROWS</> mode. They indicate that the frame starts
@@ -1789,15 +1813,13 @@ UNBOUNDED FOLLOWING
17891813 </para>
17901814
17911815 <para>
1792- The <replaceable class="parameter">frame_clause</replaceable> specifies
1793- the set of rows constituting the <firstterm>window frame</>, for those
1794- window functions that act on the frame instead of the whole partition.
17951816 The default framing option is <literal>RANGE UNBOUNDED PRECEDING</>,
17961817 which is the same as <literal>RANGE BETWEEN UNBOUNDED PRECEDING AND
1797- CURRENT ROW</>. With <literal>ORDER BY</>, this sets the frame to
1798- be all rows from partition start up through the current row's
1799- last peer. Without <literal>ORDER BY</>, all partition rows are
1800- included in the window frame.
1818+ CURRENT ROW</>. With <literal>ORDER BY</>, this sets the frame to be
1819+ all rows from the partition start up through the current row's last
1820+ peer. Without <literal>ORDER BY</>, all rows of the partition are
1821+ included in the window frame, since all rows become peers of the current
1822+ row.
18011823 </para>
18021824
18031825 <para>
0 commit comments