X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 946F79DC84D for ; Fri, 24 Mar 2006 17:34:48 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58824-03 for ; Fri, 24 Mar 2006 17:34:49 -0400 (AST) X-Greylist: delayed 01:15:05.786899 by SQLgrey- Received: from keop.polkaroo.net (cpu2218.adsl.bellglobal.com [207.236.3.195]) by postgresql.org (Postfix) with ESMTP id E6DA79DC813 for ; Fri, 24 Mar 2006 17:34:45 -0400 (AST) Received: from [134.117.194.200] (dhcp-200.gcrc.carleton.ca [134.117.194.200]) by keop.polkaroo.net (Postfix) with ESMTP id DFC191BB469A; Fri, 24 Mar 2006 16:34:46 -0500 (EST) In-Reply-To: <1143235206.90799.108.camel@home> References: <1143233215.90799.91.camel@home> <10495.1143235231@sss.pgh.pa.us> <1143235206.90799.108.camel@home> Mime-Version: 1.0 (Apple Message framework v746.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <0C305AAF-7DA6-40BF-B118-2E63C2A27748@polkaroo.net> Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit From: Amos Hayes Subject: Re: Find min and max values across two columns? Date: Fri, 24 Mar 2006 16:34:43 -0500 To: Rod Taylor , Tom Lane X-Mailer: Apple Mail (2.746.3) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.738 required=5 tests=[AWL=0.738] X-Spam-Score: 0.738 X-Spam-Level: X-Archive-Number: 200603/400 X-Sequence-Number: 24746 Your tips were great and I have hunted down the relevant pages in the docs. Thanks guys! -- Amos On 24-Mar-06, at 4:20 PM, Rod Taylor wrote: > On Fri, 2006-03-24 at 16:20 -0500, Tom Lane wrote: >> Rod Taylor writes: >>> The reason for the subselect is to prevent multiple calculations of >>> individual column aggregates. I believe it *may* be calculated >>> multiple >>> times otherwise this would work just as well: >> >>> select case when max(a) > max(b) then max(a) else max(b) end as >>> max from >>> tab; >> >> Just for the record, we've gotten that right since 7.4. greatest() >> would be a notationally cleaner solution than CASE, but multiple >> occurrences of identical aggregates don't cost much of anything. > > Thanks. I could not remember one way or the other. > > -- > > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that > your > message can get through to the mailing list cleanly