@ -1730,10 +1730,10 @@ SELECT string_agg(a ORDER BY a, ',') FROM table; -- incorrect
The syntax of a window function call is one of the following:
The syntax of a window function call is one of the following:
<synopsis>
<synopsis>
<replaceable>function_name</replaceable> (<optional><replaceable>expression</replaceable> <optional>, <replaceable>expression</replaceable> ... </optional></optional>) [ FILTER ( WHERE <replaceable>filter_clause</replaceable> ) ] OVER ( <replaceable class="parameter">window_definition</replaceable> )
<replaceable>function_name</replaceable> (<optional><replaceable>expression</replaceable> <optional>, <replaceable>expression</replaceable> ... </optional></optional>) [ FILTER ( WHERE <replaceable>filter_clause</replaceable> ) ] OVER <replaceable>window_name</replaceable>
<replaceable>function_name</replaceable> (<optional><replaceable>expression</replaceable> <optional>, <replaceable>expression</replaceable> ... </optional></optional>) [ FILTER ( WHERE <replaceable>filter_clause</replaceable> ) ] OVER <replaceable>window_name</replaceable>
<replaceable>function_name</replaceable> ( * ) [ FILTER ( WHERE <replaceable>filter_clause</replaceable> ) ] OVER ( <replaceable class="parameter">window_definition</replaceable> )
<replaceable>function_name</replaceable> (<optional><replaceable>expression</replaceable> <optional>, <replaceable>expression</replaceable> ... </optional></optional> ) [ FILTER ( WHERE <replaceable>filter_clause</replaceable> ) ] OVER ( <replaceable class="parameter">window_definition</replaceable> )
<replaceable>function_name</replaceable> ( * ) [ FILTER ( WHERE <replaceable>filter_clause</replaceable> ) ] OVER <replaceable>window_name</replaceable>
<replaceable>function_name</replaceable> ( * ) [ FILTER ( WHERE <replaceable>filter_clause</replaceable> ) ] OVER <replaceable>window_name</replaceable>
<replaceable>function_name</replaceable> ( * ) [ FILTER ( WHERE <replaceable>filter_clause</replaceable> ) ] OVER ( <replaceable class="parameter">window_definition</replaceable> )
</synopsis>
</synopsis>
where <replaceable class="parameter">window_definition</replaceable>
where <replaceable class="parameter">window_definition</replaceable>
has the syntax
has the syntax
@ -1768,15 +1768,14 @@ UNBOUNDED FOLLOWING
<para>
<para>
<replaceable>window_name</replaceable> is a reference to a named window
<replaceable>window_name</replaceable> is a reference to a named window
specification defined in the query's <literal>WINDOW</literal> clause.
specification defined in the query's <literal>WINDOW</literal> clause.
Named window specifications are usually referenced with just
Alternatively, a full <replaceable>window_definition</replaceable> can
<literal>OVER</> <replaceable>window_name</replaceable>, but it is
be given within parentheses, using the same syntax as for defining a
also possible to write a window name inside the parentheses and then
named window in the <literal>WINDOW</literal> clause; see the
optionally supply an ordering clause and/or frame clause (the referenced
<xref linkend="sql-select"> reference page for details. It's worth
window must lack these clauses, if they are supplied here).
pointing out that <literal>OVER wname</> is not exactly equivalent to
This latter syntax follows the same rules as modifying an existing
<literal>OVER (wname)</>; the latter implies copying and modifying the
window name within the <literal>WINDOW</literal> clause; see the
window definition, and will be rejected if the referenced window
<xref linkend="sql-select"> reference
specification includes a frame clause.
page for details.
</para>
</para>
<para>
<para>
@ -1853,12 +1852,19 @@ UNBOUNDED FOLLOWING
PRECEDING</literal> is not allowed.
PRECEDING</literal> is not allowed.
</para>
</para>
<para>
If <literal>FILTER</literal> is specified, then only the input
rows for which the <replaceable>filter_clause</replaceable>
evaluates to true are fed to the window function; other rows
are discarded. Only aggregate window functions accept
a <literal>FILTER</literal> clause.
</para>
<para>
<para>
The built-in window functions are described in <xref
The built-in window functions are described in <xref
linkend="functions-window-table">. Other window functions can be added by
linkend="functions-window-table">. Other window functions can be added by
the user. Also, any built-in or user-defined aggregate function can be
the user. Also, any built-in or user-defined aggregate function can be
used as a window function. Only aggregate window functions accept
used as a window function.
a <literal>FILTER</literal> clause.
</para>
</para>
<para>
<para>