Received: from localhost (uranus.hub.org [200.46.204.60]) by postgresql.org (Postfix) with ESMTP id D6BBD9FA1DB for ; Mon, 13 Nov 2006 11:07:03 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.60]) (amavisd-new, port 10024) with ESMTP id 76114-04 for ; Mon, 13 Nov 2006 11:07:02 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id D60509FA18A for ; Mon, 13 Nov 2006 11:07:01 -0400 (AST) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id kADF6igO044960 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 13 Nov 2006 08:06:47 -0700 (MST) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.8/8.13.8) with ESMTP id kADF6iAT035101; Mon, 13 Nov 2006 08:06:44 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.8/8.13.8/Submit) id kADF6h4b035100; Mon, 13 Nov 2006 08:06:44 -0700 (MST) (envelope-from mfuhr) Date: Mon, 13 Nov 2006 08:06:43 -0700 From: Michael Fuhr To: imad Cc: "A. Kretschmer" , pgsql-sql@postgresql.org Subject: Re: max (timestamp,timestamp) Message-ID: <20061113150643.GA34908@winnie.fuhr.org> References: <45587718.2010009@numerixtechnology.de> <20061113140828.GD14281@a-kretschmer.de> <1f30b80c0611130629v4616365cr50c8fd99f01fce3a@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1f30b80c0611130629v4616365cr50c8fd99f01fce3a@mail.gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/130 X-Sequence-Number: 26782 On Mon, Nov 13, 2006 at 07:29:09PM +0500, imad wrote: > max (timestamptz, timestamptz) does not exist already. You need to > create a simple function in PLpgSQL something like > > if a > b > return a; > else > return b; Since PostgreSQL 8.1 you can use GREATEST: test=> SELECT greatest(1, 2); greatest ---------- 2 (1 row) test=> SELECT greatest(2, 1); greatest ---------- 2 (1 row) test=> SELECT greatest(6, 3, 1, 10, 9, 5, 2, 7, 8, 4); greatest ---------- 10 (1 row) -- Michael Fuhr