Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 9BC6C1337BA6 for ; Mon, 17 Jan 2011 11:11:44 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 54168-07 for ; Mon, 17 Jan 2011 15:11:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from spinlock.commandprompt.com (unknown [207.173.203.215]) by mail.postgresql.org (Postfix) with ESMTP id 3731C1337B4A for ; Mon, 17 Jan 2011 11:11:36 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by spinlock.commandprompt.com (Postfix) with ESMTP id 355B6348025; Mon, 17 Jan 2011 07:11:14 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at commandprompt.com Received: from spinlock.commandprompt.com ([127.0.0.1]) by localhost (spinlock.commandprompt.com.commandprompt.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CM4zx0OaokHB; Mon, 17 Jan 2011 07:11:12 -0800 (PST) Received: from perhan.alvh.no-ip.org (unknown [186.9.186.58]) by spinlock.commandprompt.com (Postfix) with ESMTPSA id 9D86C348024; Mon, 17 Jan 2011 07:11:11 -0800 (PST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 39F946E609; Mon, 17 Jan 2011 12:10:19 -0300 (CLST) Content-Type: text/plain; charset=UTF-8 Cc: pgsql-bugs Subject: Re: BUG #5841: rank()+1 fails, 1+rank() succeeds From: Alvaro Herrera To: Jeff Turner In-reply-to: <201101171034.p0HAYTE7056475@wwwmaster.postgresql.org> References: <201101171034.p0HAYTE7056475@wwwmaster.postgresql.org> Date: Mon, 17 Jan 2011 12:10:19 -0300 Message-Id: <1295276957-sup-5631@alvh.no-ip.org> User-Agent: Sup/git Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.107 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RDNS_NONE=0.793 X-Spam-Level: X-Archive-Number: 201101/123 X-Sequence-Number: 29145 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 The PostgreSQL Company - Command Prompt, Inc. PostgreSQL Replication, Consulting, Custom Development, 24x7 support