Re: max (timestamp,timestamp)

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: imad <immaad(at)gmail(dot)com>
Cc: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: max (timestamp,timestamp)
Date: 2006-11-13 15:06:43
Message-ID: 20061113150643.GA34908@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message ivan marchesini 2006-11-13 16:32:06 drop a check
Previous Message imad 2006-11-13 14:29:09 Re: max (timestamp,timestamp)