From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Stefano Bonnin <stefano(dot)bonnin(at)comai(dot)to> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Temporal query question |
Date: | 2004-11-30 11:12:35 |
Message-ID: | 20041130111230.GA30959@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
The usual syntax is something like:
select myfield,numeric_field
from mytable
where temporal_attribute_a < temporal_attribute_b - ( numeric_field * '1 day'::interval);
One of the temporal_attributes tends to be 'now' or 'today' but the
principle is the same...
On Tue, Nov 30, 2004 at 11:30:16AM +0100, Stefano Bonnin wrote:
> Hi all,
>
> I have a "simple" question about the following temporal query with "interval" operator:
>
> can I define a query of this type?
>
> select myfield,numeric_field from mytable where temporal_attribute < temporal_attribute - interval numeric_field || ' days'
>
> obviously this syntax is wrong.
> In other words, is there a way to define a query with a interval operator with variable argument?
> Thanks
> Stefano
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2004-11-30 11:15:57 | Re: change natural column order |
Previous Message | Tino Wildenhain | 2004-11-30 11:03:33 | Re: Maximum limit on int in plpgsql |