Re: greatest/least semantics different between oracle and postgres

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Gregory Stark <stark(at)enterprisedb(dot)com>
Cc: Bruno Wolff III <bruno(at)wolff(dot)to>, Andrej Ricnik-Bay <andrej(dot)groups(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: greatest/least semantics different between oracle and postgres
Date: 2007-06-30 15:34:50
Message-ID: 25612.1183217690@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gregory Stark <stark(at)enterprisedb(dot)com> writes:
> "Bruno Wolff III" <bruno(at)wolff(dot)to> writes:
>> Also what value should I have used in a coalesce to guaranty still getting
>> the maximum?

> I would expect coalesce(coalesce(greatest(a,b),a),b) to do what you want. It's
> not terribly legible though and if a and b are subselects I would worry a
> little about the optimizer rerunning them unnecessarily.

That does not work correctly for volatile functions, and it does not
scale to more than two inputs either -- you'd get the first nonnull
not the largest one.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-06-30 15:45:25 Re: greatest/least semantics different between oracle and postgres
Previous Message Oleg Bartunov 2007-06-30 15:30:56 Re: stem & tsearch2, want different stemmed words