Re: SQL question

From: "Adam Rich" <adam(dot)r(at)sbcglobal(dot)net>
To: "'kevin kempter'" <kevin(at)kevinkempterllc(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL question
Date: 2008-03-29 05:03:33
Message-ID: 06a901c8915a$3d46e680$b7d4b380$@r@sbcglobal.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I have a table that has 3 date columns :
>
> create table xyz (
> xyz_id integer,
> date1 timestamp,
> date2 timestamp,
> date3 timestamp
> )
>
>
> I want to select in a query the xyz_id and the max date column for
> each row
> something like :
> create table temp2 as select xyz_id (max date?) where ...

Is this what you want?

Select xyz_id, greatest(date1,date2,date3) from xyz where...

http://www.postgresql.org/docs/8.3/interactive/functions-conditional.html#AE
N14508

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Shane Ambler 2008-03-29 06:44:21 Re: Using tables in other PostGreSQL database
Previous Message kevin kempter 2008-03-29 04:59:28 SQL question