The following bug has been logged online:
Bug reference: 5841
Logged by: Jeff Turner
Email address: jeff(at)biccard(dot)com
PostgreSQL version: 9.0.1
Operating system: Ubuntu 10.10
Description: rank()+1 fails, 1+rank() succeeds
Details:
Given a table:
create table t (foo varchar, bar integer);
insert into t values ('a', 1), ('b', 2), ('c', 1);
This query succeeds:
select *, 1+rank() over (partition by bar) from t;
However, replace '1+rank()' with 'rank()+1' and it fails:
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;