pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adam Rich <adam.r@sbcglobal.net>
To: 'kevin kempter' <kevin@kevinkempterllc.com>
To: pgsql-general@postgresql.org
Subject: Re: SQL question
Date: Sat, 29 Mar 2008 00:03:33 -0500
Message-ID: <06a901c8915a$3d46e680$b7d4b380$@r@sbcglobal.net> (raw)
In-Reply-To: <69712BCF-F10A-4874-BD7D-9A40E1474E19@kevinkempterllc.com>
References: <69712BCF-F10A-4874-BD7D-9A40E1474E19@kevinkempterllc.com>

> 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






view thread (71+ messages)  latest in thread

Message-ID: <06a901c8915a$3d46e680$b7d4b380$@r@sbcglobal.net>
Permalink:  ../06a901c8915a$3d46e680$b7d4b380$@r@sbcglobal.net/
Also on:    postgresql.org/message-id/06a901c8915a$3d46e680$b7d4b380$@r@sbcglobal.net

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adam.r@sbcglobal.net, kevin@kevinkempterllc.com
  Subject: Re: SQL question
  In-Reply-To: <06a901c8915a$3d46e680$b7d4b380$@r@sbcglobal.net>
  References: <69712BCF-F10A-4874-BD7D-9A40E1474E19@kevinkempterllc.com> <06a901c8915a$3d46e680$b7d4b380$@r@sbcglobal.net>

* 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