pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: imad <immaad@gmail.com>
Cc: A. Kretschmer <andreas.kretschmer@schollglas.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: max (timestamp,timestamp)
Date: Mon, 13 Nov 2006 08:06:43 -0700
Message-ID: <20061113150643.GA34908@winnie.fuhr.org> (raw)
In-Reply-To: <1f30b80c0611130629v4616365cr50c8fd99f01fce3a@mail.gmail.com>
References: <45587718.2010009@numerixtechnology.de>
	<20061113140828.GD14281@a-kretschmer.de>
	<1f30b80c0611130629v4616365cr50c8fd99f01fce3a@mail.gmail.com>

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



view thread (5+ messages)  latest in thread

Message-ID: <20061113150643.GA34908@winnie.fuhr.org>
Permalink:  ../20061113150643.GA34908@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20061113150643.GA34908@winnie.fuhr.org

 · 

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: mike@fuhr.org, immaad@gmail.com, andreas.kretschmer@schollglas.com
  Subject: Re: max (timestamp,timestamp)
  In-Reply-To: <20061113150643.GA34908@winnie.fuhr.org>

* 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