Re: Max/min of 2 values function, plpgsql efficency? - Mailing list pgsql-general

From Tom Lane
Subject Re: Max/min of 2 values function, plpgsql efficency?
Date
Msg-id 29991.1078250056@sss.pgh.pa.us
Whole thread Raw
In response to Max/min of 2 values function, plpgsql efficency?  ("Karl O. Pinc" <kop@meme.com>)
List pgsql-general
"Karl O. Pinc" <kop@meme.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

pgsql-general by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: max table size
Next
From: "Knepper, Michelle"
Date:
Subject: Re: using the "copy from" command