Re: Find min and max values across two columns?

From: Amos Hayes <ahayes(at)polkaroo(dot)net>
To: Rod Taylor <pg(at)rbt(dot)ca>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Find min and max values across two columns?
Date: 2006-03-24 21:34:43
Message-ID: 0C305AAF-7DA6-40BF-B118-2E63C2A27748@polkaroo.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


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 <pg(at)rbt(dot)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.
>
> --
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that
> your
> message can get through to the mailing list cleanly

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Daniel Caune 2006-03-24 22:13:15 Index on nullable column
Previous Message Tom Lane 2006-03-24 21:20:31 Re: Find min and max values across two columns?