Re: new max function

From: Mike Rylander <miker(at)n2bb(dot)com>
To: Rodrigo Gesswein <rodri(at)chilesat(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: new max function
Date: 2003-10-17 21:32:50
Message-ID: 200310171732.50292.miker@n2bb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Here's mine:

CREATE FUNCTION max2 (INTEGER,INTEGER) RETURNS INTEGER
LANGUAGE SQL AS
'SELECT CASE WHEN $1 > $2 THEN $1 ELSE $2 END';

This returns:

database=# select max2(1,2);
max2
------
2
(1 row)

database=# select max2(3,1);
max2
------
3
(1 row)

On Friday 17 October 2003 02:13 pm, Rodrigo Gesswein wrote:
> Hello!
>
> I'm looking for a function to calculate the max value from two numbers,
> something like max2(a,b) with a,b int
>
> Does anyone have the trick ?
>
> Thank you in advance..
>
> Rodrigo!
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: 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

--
Mike Rylander

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2003-10-18 02:51:52 Re: new max function
Previous Message Rodrigo Gesswein 2003-10-17 18:13:18 new max function