Skip site navigation (1) Skip section navigation (2)

Re: BUG #5841: rank()+1 fails, 1+rank() succeeds

From: jeff(at)biccard(dot)com
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #5841: rank()+1 fails, 1+rank() succeeds
Date: 2011-01-18 11:19:07
Message-ID: 20110118221907.u4f00r2ss4kwc8kw@webmail.biccard.com (view raw or flat)
Thread:
Lists: pgsql-bugs
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 <alvherre(at)commandprompt(dot)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 <alvherre(at)commandprompt(dot)com>
> The PostgreSQL Company - Command Prompt, Inc.
> PostgreSQL Replication, Consulting, Custom Development, 24x7 support
>



Attachment: doc_window_function.diff
Description: text/x-patch (1.3 KB)

In response to

Responses

pgsql-bugs by date

Next:From: benoygopalDate: 2011-01-18 14:27:45
Subject: Re: BUG #5791: Tables are not viewing through pgadmin
Previous:From: Tom LaneDate: 2011-01-18 02:52:50
Subject: Re: Problems with adding a is not null to a query.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group