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

2007-04-10 Thread John D. Burger
SELECT min(x) FROM ( SELECT min(datecol1) AS x FROM table1 UNION ALL SELECT min(datecol2) AS x FROM table2 UNION ALL SELECT min(datecol3) AS x FROM table3 ) ss; Exercise for newbie: which of the AS clauses are redundant? Um, all of them? Yah, but only if you do this: SELECT min(*) FROM (

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

2007-04-10 Thread Lorenzo Thurman
Tom Lane wrote: "Dann Corbit" <[EMAIL PROTECTED]> writes: [EMAIL PROTECTED] On Behalf Of Lorenzo Thurman 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? Just do a union and return

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

2007-04-10 Thread Lorenzo Thurman
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 (se

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

2007-04-10 Thread Lorenzo Thurman
Brent Wood wrote: 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? You could write a custom function doing the same sort of thing, or (perhaps more portable) u

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

2007-04-09 Thread Brent Wood
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? You could write a custom function doing the same sort of thing, or (perhaps more portable) use generic sqls & v

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

2007-04-09 Thread Merlin Moncure
On 4/9/07, Tom Lane <[EMAIL PROTECTED]> wrote: "Dann Corbit" <[EMAIL PROTECTED]> writes: >> [EMAIL PROTECTED] On Behalf Of Lorenzo Thurman >> 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 wou

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

2007-04-09 Thread Tom Lane
"Dann Corbit" <[EMAIL PROTECTED]> writes: >> [EMAIL PROTECTED] On Behalf Of Lorenzo Thurman >> 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? > Just do a union and return the min

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

2007-04-09 Thread Dann Corbit
Just do a union and return the min > -Original Message- > From: [EMAIL PROTECTED] [mailto:pgsql-general- > [EMAIL PROTECTED] On Behalf Of Lorenzo Thurman > Sent: Monday, April 09, 2007 7:32 AM > To: pgsql-general@postgresql.org > Subject: [GENERAL] NEWBIE: How do I g

[GENERAL] NEWBIE: How do I get the oldest date contained in 3 tables

2007-04-09 Thread Lorenzo Thurman
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 ---(end of broadcast)--- TIP 6: explain analyze is your friend