pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Larry Lennhoff <llennhoff-postgres@pexicom.com>
To: pgsql-sql@postgresql.org
Subject: Create interval using column value?
Date: Sun, 24 Oct 2004 22:54:33 -0400
Message-ID: <6.0.2.0.0.20041024224504.03b5c7c8@localhost> (raw)

Hi

I have a table (A) with a integer column called build_interval, which 
contains the number of milliseconds betweeen builds.  I have another table 
(B) with a timestamp with timezone column called built_on.  The two tables 
share a column called join_col.  What I want to do is find all the rows in 
A which were built before now() - build_interval seconds ago.  If I could 
just write this in SQL it would look something like:

SELECT A.id FROM A JOIN B ON (join_col) WHERE built_on < now() - interval 
'build_interval seconds';  This does not work at all - I cannot find a way 
to build an interval using a column - casting an integer as an interval is 
forbidden. Can anyone suggest a way to achieve my desired result? I'm not 
wedded to the interval approach.  I can probably change the column type of 
build_interval if necessary.

I am using postgres 7.3.4

Thanks in advance for any help.




view thread (4+ messages)  latest in thread

Message-ID: <6.0.2.0.0.20041024224504.03b5c7c8@localhost>
Permalink:  ../6.0.2.0.0.20041024224504.03b5c7c8@localhost/
Also on:    postgresql.org/message-id/6.0.2.0.0.20041024224504.03b5c7c8@localhost

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: llennhoff-postgres@pexicom.com
  Subject: Re: Create interval using column value?
  In-Reply-To: <6.0.2.0.0.20041024224504.03b5c7c8@localhost>

* 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