pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rod Taylor <pg@rbt.ca>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Amos Hayes <ahayes@polkaroo.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Find min and max values across two columns?
Date: Fri, 24 Mar 2006 16:20:06 -0500
Message-ID: <1143235206.90799.108.camel@home> (raw)
In-Reply-To: <10495.1143235231@sss.pgh.pa.us>
References: <DAD4674C-1896-4F24-B43B-B884491DB931@polkaroo.net>
	<1143233215.90799.91.camel@home>
	<10495.1143235231@sss.pgh.pa.us>

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.

-- 




view thread (11+ messages)  latest in thread

Message-ID: <1143235206.90799.108.camel@home>
Permalink:  ../1143235206.90799.108.camel@home/
Also on:    postgresql.org/message-id/1143235206.90799.108.camel@home

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pg@rbt.ca, tgl@sss.pgh.pa.us, ahayes@polkaroo.net
  Subject: Re: Find min and max values across two columns?
  In-Reply-To: <1143235206.90799.108.camel@home>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox