Thanks for clarifying. I've submitted a note on the interactive
version of the docs, and attached a small patch to make explicit that
a window function is followed _immediately_ by an OVER clause, as the
syntax[1] indicates.
Regards,
Jeff
[1]
http://www.postgresql.org/docs/current/static/sql-expressions.html#SYNTAX-WINDOW-FUNCTIONS
Quoting Alvaro Herrera <alvhe...@commandprompt.com>:
Excerpts from Jeff Turner's message of lun ene 17 07:34:29 -0300 2011:
test=# select *, rank()+1 over (partition by bar) from t;
ERROR: syntax error at or near "over"
LINE 1: select *, rank()+1 over (partition by bar) from t;
The "over" stuff is part of the expression; you can't add the +1 in the
middle. This works:
select *, rank() over (partition by bar) + 1 from t;
--
Ãlvaro Herrera <alvhe...@commandprompt.com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
diff --git a/doc/src/sgml/advanced.sgml b/doc/src/sgml/advanced.sgml
index 784b40a..9cb7173 100644
--- a/doc/src/sgml/advanced.sgml
+++ b/doc/src/sgml/advanced.sgml
@@ -371,7 +371,7 @@ SELECT depname, empno, salary, avg(salary) OVER (PARTITION BY depname) FROM emps
<para>
A window function call always contains an <literal>OVER</> clause
- following the window function's name and argument(s). This is what
+ directly following the window function's name and argument(s). This is what
syntactically distinguishes it from a regular function or aggregate
function. The <literal>OVER</> clause determines exactly how the
rows of the query are split up for processing by the window function.
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 04769f1..88345ec 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -11184,8 +11184,8 @@ SELECT xmlagg(x) FROM (SELECT x FROM test ORDER BY y DESC) AS tab;
<para>
The built-in window functions are listed in
<xref linkend="functions-window-table">. Note that these functions
- <emphasis>must</> be invoked using window function syntax; that is an
- <literal>OVER</> clause is required.
+ <emphasis>must</> be invoked using window function syntax; that is must
+ be immediately followed by an <literal>OVER</> clause.
</para>
<para>
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs