Re: NEWBIE: How do I get the oldest date contained in 3 tables

From: Lorenzo Thurman <lorenzo(at)diespammerhethurmans(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: NEWBIE: How do I get the oldest date contained in 3 tables
Date: 2007-04-09 18:36:15
Message-ID: jldqe4-383.ln1@Hedley.internal.thethurmans.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Lorenzo Thurman wrote:
> I have three tables using date fields. I want to retrieve the oldest
> date contained in the tables. Can someone show me an example of a query
> that would do that?
> TIA

I think I have it, but if anyone has any comments, I'd appreciate it:

select min(old) as oldest from (select distinct min(create) as old from tab1
UNION
select distinct min(time_now) as old from tab1
UNION
select distinct min(create_time) as old from tab2)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Geoffrey 2007-04-09 18:43:24 Re: backend reset of database
Previous Message Magnus Hagander 2007-04-09 18:32:31 Re: backend reset of database