From: Jean-Christophe Boggio <cat@thefreecat.org>
To: Brian C. Doyle <bcdoyle@mindspring.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: if else query help
Date: Thu, 12 Oct 2000 16:56:53 +0200
Message-ID: <6812102772.20001012165653@thefreecat.org> (raw)
In-Reply-To: <5.0.0.25.2.20001012094914.081abeb0@pop.mindspring.com>
References: <5.0.0.25.2.20001012094914.081abeb0@pop.mindspring.com>
hi Brian,
BCD> I need to write a query that will pull information from table2 if
BCD> information in table1 is older then xdate.
BCD> My laymen example:
BCD> SELECT table2.date, count(table2.name) as count
BCD> WHERE table1.startdate > 2 weeks
BCD> AND table2.submitdate > 2 weeks
BCD> ;
BCD> So i Guess my real questions is how do I determine the age of an entry to
BCD> another table?
Try this :
Select table2.date,count(table2.name) as count
from table1 as t1, table2 as t2
where t1.itemid=t2.itemid -- to link the tables
and t1.startdate>now()-14
and t2.submitdate>now()-14;
Someone corrects me if I'm wrong, I come from the Oracle world...
Dates (or I should say TimeStamps) are stored as floating point values
: the integer part is the number of days since a certain date
(epoch or 01/01/1970 on unix-based databases) and the fractionnal part is the
portion of the day (although I don't know --yet-- how to convert
date2-date1 to an integer, trunc does not work).
HTH
--
Jean-Christophe Boggio
cat@thefreecat.org
Independant Consultant and Developer
Delphi, Linux, Oracle, Perl
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-sql@postgresql.org
Cc: cat@thefreecat.org, bcdoyle@mindspring.com
Subject: Re: if else query help
In-Reply-To: <6812102772.20001012165653@thefreecat.org>
References: <5.0.0.25.2.20001012094914.081abeb0@pop.mindspring.com> <6812102772.20001012165653@thefreecat.org>
* 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