Re: Find min and max values across two columns? - Mailing list pgsql-sql

From Rod Taylor
Subject Re: Find min and max values across two columns?
Date
Msg-id 1143235206.90799.108.camel@home
Whole thread Raw
In response to Re: Find min and max values across two columns?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Find min and max values across two columns?
List pgsql-sql
On Fri, 2006-03-24 at 16:20 -0500, Tom Lane wrote:
> Rod Taylor <pg@rbt.ca> 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.

-- 



pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: Find min and max values across two columns?
Next
From: Don Maier
Date:
Subject: Expressing a result set as an array (and vice versa)?