Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C7D896326EB for ; Thu, 4 Mar 2010 16:18:53 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 61748-01 for ; Thu, 4 Mar 2010 20:18:43 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from out01.mta.xmission.com (out01.mta.xmission.com [166.70.13.231]) by mail.postgresql.org (Postfix) with ESMTP id 55E7B63322E for ; Thu, 4 Mar 2010 16:18:43 -0400 (AST) Received: from in01.mta.xmission.com ([166.70.13.51]) by out01.mta.xmission.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1NnHVJ-0005PJ-GG; Thu, 04 Mar 2010 13:18:41 -0700 Received: from [208.187.158.94] (helo=[172.16.1.231]) by in01.mta.xmission.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1NnHVJ-0001zQ-CX; Thu, 04 Mar 2010 13:18:41 -0700 Message-ID: <4B901607.2090409@gmail.com> Date: Thu, 04 Mar 2010 13:20:23 -0700 From: Rob Sargent User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.7) Gecko/20100111 Lightning/1.0b1 Thunderbird/3.0.1 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; format=flowed Content-Transfer-Encoding: 7bit X-XM-SPF: eid=; ; ; mid=; ; ; hst=in01.mta.xmission.com; ; ; ip=208.187.158.94; ; ; frm=robjsargent@gmail.com; ; ; spf=neutral X-SA-Exim-Connect-IP: 208.187.158.94 X-SA-Exim-Mail-From: robjsargent@gmail.com X-SA-Exim-Scanned: No (on in01.mta.xmission.com); SAEximRunCond expanded to false X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/30 X-Sequence-Number: 33737 'select max(col) where col < max(col)' should work but you have to do 'where col < (select max(col) ' On 03/04/2010 01:09 PM, Louis-David Mitterrand wrote: > Hi, > > With builtin aggregates is it possible to return the value just before > max(col)? > > Thanks, >