X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E5B98D1B4E1 for ; Fri, 17 Oct 2003 21:45:58 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 28639-05 for ; Fri, 17 Oct 2003 18:45:28 -0300 (ADT) Received: from mail2.n2bb.com (mail2.n2bb.com [66.0.13.202]) by svr1.postgresql.org (Postfix) with ESMTP id 12C92D1B4EC for ; Fri, 17 Oct 2003 18:45:26 -0300 (ADT) Received: from n2-atl-mrylander.it.n2bb.com ([10.250.10.96]) by mail2.n2bb.com with Microsoft SMTPSVC(5.0.2195.6713); Fri, 17 Oct 2003 17:46:31 -0400 Content-Type: text/plain; charset="iso-8859-1" From: Mike Rylander Reply-To: miker@n2bb.com Organization: N2 Broadband To: Rodrigo Gesswein , pgsql-sql@postgresql.org Subject: Re: new max function Date: Fri, 17 Oct 2003 17:32:50 -0400 User-Agent: KMail/1.4.3 References: In-Reply-To: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-Id: <200310171732.50292.miker@n2bb.com> X-OriginalArrivalTime: 17 Oct 2003 21:46:31.0393 (UTC) FILETIME=[20764D10:01C394F8] X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/216 X-Sequence-Number: 15616 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