Re: Max/min of 2 values function, plpgsql efficency?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Karl O(dot) Pinc" <kop(at)meme(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Max/min of 2 values function, plpgsql efficency?
Date: 2004-03-02 17:54:16
Message-ID: 29991.1078250056@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Karl O. Pinc" <kop(at)meme(dot)com> writes:
> I'd like to write:
> SELECT larger(colA, colB) FROM foo
> and am wondering the best way to go about it.

> Does somebody have a good solution? (I don't suppose there's
> something built-in that I'm missing?)

All the standard datatypes have built-in two-argument larger()
functions, though they're generally named something more obscure
than that; try \df *larger*. The MAX and MIN aggregates require
larger() and smaller() functions --- if you can't find the function
you want by name, look into pg_aggregate to see what the transition
function for the relevant aggregate is.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message scrappy 2004-03-02 18:00:40 stacy
Previous Message Floyd Shackelford 2004-03-02 17:53:56 Composite types in tables