Thread: getting min/max of two values

getting min/max of two values

From
rihad
Date:
How can I efficiently return the minimum/maximum of two given
expressions? Like SELECT MYMIN(a+b-c,d+e*f).

Thanks.

Re: getting min/max of two values

From
"Pavel Stehule"
Date:
2007/9/15, rihad <rihad@mail.ru>:
> How can I efficiently return the minimum/maximum of two given
> expressions? Like SELECT MYMIN(a+b-c,d+e*f).
>
> Thanks.

Hello

use function GREATEST (maximim) or LEAST (minimum)

http://www.postgresql.org/docs/8.2/interactive/functions-conditional.html#AEN13148

Regards
Pavel Stehule

Re: getting min/max of two values

From
Jeff Davis
Date:
On Sat, 2007-09-15 at 12:40 +0500, rihad wrote:
> How can I efficiently return the minimum/maximum of two given
> expressions? Like SELECT MYMIN(a+b-c,d+e*f).
>

SELECT LEAST(a+b-c,d+e*f);
SELECT GREATEST(a+b-c,d+e*f);

Regards,
    Jeff Davis