Received: from maia.hub.org (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id BB055633CD7 for ; Thu, 4 Mar 2010 16:19:25 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 39799-02-6 for ; Thu, 4 Mar 2010 20:19:11 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.fmed.uba.ar (mail.fmed.uba.ar [157.92.152.1]) by mail.postgresql.org (Postfix) with ESMTP id F3B43633D9B for ; Thu, 4 Mar 2010 16:19:09 -0400 (AST) Received: from [157.92.152.105] (unknown [157.92.152.105]) by mail.fmed.uba.ar (Postfix) with ESMTP id 509B339CF4A for ; Thu, 4 Mar 2010 17:17:47 -0200 (ARST) Message-ID: <4B901488.6080502@fmed.uba.ar> Date: Thu, 04 Mar 2010 17:14:00 -0300 From: Gerardo Herzig User-Agent: Thunderbird 2.0.0.6 (X11/20070801) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: an aggregate to return max() - 1 value? References: <20100304200913.GA24865@apartia.fr> In-Reply-To: <20100304200913.GA24865@apartia.fr> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.374 tagged_above=-10 required=5 tests=AWL=-0.189, BAYES_40=-0.185 X-Spam-Level: X-Archive-Number: 201003/31 X-Sequence-Number: 33738 Louis-David Mitterrand wrote: > Hi, > > With builtin aggregates is it possible to return the value just before > max(col)? > > Thanks, > Mmmm what about select max(col) from table where col not in (select max(col) from table; ? Looks like a double table reading, but it works. Gerardo