pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mike Rylander <miker@n2bb.com>
To: Rodrigo Gesswein <rodri@chilesat.net>
To: pgsql-sql@postgresql.org
Subject: Re: new max function
Date: Fri, 17 Oct 2003 17:32:50 -0400
Message-ID: <200310171732.50292.miker@n2bb.com> (raw)
In-Reply-To: <Pine.LNX.4.56.0310171510400.6271@pluton.chilepac.com>
References: <Pine.LNX.4.56.0310171510400.6271@pluton.chilepac.com>


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@postgresql.org so that your
>       message can get through to the mailing list cleanly

-- 
Mike Rylander




view thread (3+ messages)  latest in thread

Message-ID: <200310171732.50292.miker@n2bb.com>
Permalink:  ../200310171732.50292.miker@n2bb.com/
Also on:    postgresql.org/message-id/200310171732.50292.miker@n2bb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: miker@n2bb.com, rodri@chilesat.net
  Subject: Re: new max function
  In-Reply-To: <200310171732.50292.miker@n2bb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox