Copy-editing for recent window-functions documentation rewrite.
authorTom Lane
Fri, 17 Aug 2012 19:40:35 +0000 (15:40 -0400)
committerTom Lane
Fri, 17 Aug 2012 19:40:35 +0000 (15:40 -0400)
Fix grammar, put back some removed information, rearrange for clarity.

doc/src/sgml/syntax.sgml

index 067c31b2d87dbdae43bbb427ef5fae802b4d3fc9..12362e779fb8bb945c8a5cfd4b2691ef1e918b95 100644 (file)
@@ -1742,13 +1742,6 @@ UNBOUNDED FOLLOWING
    
     Here, expression represents any value
     expression that does not itself contain window function calls.
-    PARTITION BY behaves like a GROUP
-    BY clause by grouping rows into partitions, except its
-    expressions are always just expressions and cannot be output-column
-    names or numbers.   ORDER BY behaves similar to a
-    query-level ORDER BY clause, except it controls the
-    order rows are supplied to the aggregate function within the window
-    frame, and with the same expression restrictions.
    
 
    
@@ -1766,18 +1759,49 @@ UNBOUNDED FOLLOWING
    
 
    
-    In RANGE mode, CURRENT ROW starts with
-    the current row's first peer that ORDER BY
-    considers equivalent, and ends with its last equivalent peer.  In 
-    ROWS mode, CURRENT ROW simply starts and ends
-    with the current row.
+    The PARTITION BY option groups the rows of the query into
+    partitions, which are processed separately by the window
+    function.  PARTITION BY works similarly to a query-level
+    GROUP BY clause, except that its expressions are always just
+    expressions and cannot be output-column names or numbers.
+    Without PARTITION BY, all rows produced by the query are
+    treated as a single partition.
+    The ORDER BY option determines the order in which the rows
+    of a partition are processed by the window function.  It works similarly
+    to a query-level ORDER BY clause, but likewise cannot use
+    output-column names or numbers.  Without ORDER BY, rows are
+    processed in an unspecified order.
+   
+
+   
+    The frame_clause specifies
+    the set of rows constituting the window frame, which is a
+    subset of the current partition, for those window functions that act on
+    the frame instead of the whole partition.  The frame can be specified in
+    either RANGE or ROWS mode; in either case, it
+    runs from the frame_start to the
+    frame_end.  If frame_end is omitted,
+    it defaults to CURRENT ROW.
+   
+
+   
+    A frame_start of UNBOUNDED PRECEDING means
+    that the frame starts with the first row of the partition, and similarly
+    a frame_end of UNBOUNDED FOLLOWING means
+    that the frame ends with the last row of the partition.
+   
+
+   
+    In RANGE mode, a frame_start of
+    CURRENT ROW means the frame starts with the current row's
+    first peer row (a row that ORDER BY considers
+    equivalent to the current row), while a frame_end of
+    CURRENT ROW means the frame ends with the last equivalent
+    peer.  In ROWS mode, CURRENT ROW simply means
+    the current row.
    
 
    
-    UNBOUNDED PRECEDING means that the frame
-    starts with the first row of the partition, and similarly
-    UNBOUNDED FOLLOWING means that the frame ends with the last
-    row of the partition.
     The value PRECEDING and
     value FOLLOWING cases are currently only
     allowed in ROWS mode.  They indicate that the frame starts
@@ -1789,15 +1813,13 @@ UNBOUNDED FOLLOWING
    
 
    
-    The frame_clause specifies
-    the set of rows constituting the window frame, for those
-    window functions that act on the frame instead of the whole partition.
     The default framing option is RANGE UNBOUNDED PRECEDING,
     which is the same as RANGE BETWEEN UNBOUNDED PRECEDING AND
-    CURRENT ROW.  With ORDER BY, this sets the frame to
-    be all rows from partition start up through the current row's
-    last peer.  Without ORDER BY, all partition rows are
-    included in the window frame.
+    CURRENT ROW.  With ORDER BY, this sets the frame to be
+    all rows from the partition start up through the current row's last
+    peer.  Without ORDER BY, all rows of the partition are
+    included in the window frame, since all rows become peers of the current
+    row.