From: Tom Lane <tgl@sss.pgh.pa.us>
To: miker@n2bb.com
Cc: Rodrigo Gesswein <rodri@chilesat.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: new max function
Date: Fri, 17 Oct 2003 22:51:52 -0400
Message-ID: <27573.1066445512@sss.pgh.pa.us> (raw)
In-Reply-To: <200310171732.50292.miker@n2bb.com>
References: <Pine.LNX.4.56.0310171510400.6271@pluton.chilepac.com>
<200310171732.50292.miker@n2bb.com>
Mike Rylander <miker@n2bb.com> writes:
> Here's mine:
> CREATE FUNCTION max2 (INTEGER,INTEGER) RETURNS INTEGER
> LANGUAGE SQL AS
> 'SELECT CASE WHEN $1 > $2 THEN $1 ELSE $2 END';
BTW, most of the standard datatypes have these already, because they are
the transition functions for the MAX() and MIN() aggregates. The one
above is int4larger().
regression=# \df *larger
List of functions
Result data type | Schema | Name | Argument data types
-----------------------------+------------+--------------------+----------------------------------------------------------
money | pg_catalog | cashlarger | money, money
date | pg_catalog | date_larger | date, date
real | pg_catalog | float4larger | real, real
double precision | pg_catalog | float8larger | double precision, double precision
smallint | pg_catalog | int2larger | smallint, smallint
integer | pg_catalog | int4larger | integer, integer
bigint | pg_catalog | int8larger | bigint, bigint
interval | pg_catalog | interval_larger | interval, interval
numeric | pg_catalog | numeric_larger | numeric, numeric
oid | pg_catalog | oidlarger | oid, oid
text | pg_catalog | text_larger | text, text
time without time zone | pg_catalog | time_larger | time without time zone, time without time zone
timestamp without time zone | pg_catalog | timestamp_larger | timestamp without time zone, timestamp without time zone
timestamp with time zone | pg_catalog | timestamptz_larger | timestamp with time zone, timestamp with time zone
time with time zone | pg_catalog | timetz_larger | time with time zone, time with time zone
(15 rows)
All of these have matching xxxsmaller() as well.
regards, tom lane
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: tgl@sss.pgh.pa.us, miker@n2bb.com, rodri@chilesat.net
Subject: Re: new max function
In-Reply-To: <27573.1066445512@sss.pgh.pa.us>
* 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