[postgis-users] Help with query

Stephen Woodbridge woodbri at swoodbridge.com
Fri Nov 3 13:14:45 PST 2006


Pedro,

In general there is no association between records in the database 
unless you explicitly associate them. In fact two records that you 
insert from process A might not actually be adjacent in the database if 
other processes are inserting also.

So what you need to do is create a column like 'process_id' where 
process_id is a unique identifier for a sequence of steps then you can 
select all those records and order then by the timestamp and then you 
can compute the time differences.

-Steve

Pedro Doria Meunier wrote:
> 
> 
> This is probably not the best place to be asking such a (lame) question 
> but perhaps someone is gracious enough to lend me a hand… ;-)
> 
>  
> 
> I have the following setup in a table:
> 
>  
> 
> The first record which is to be found (ok easy enough :D) with a 
> timestamp meets a certain condition (ignition off)
> 
> The following record is for the event of ignition on again with a 
> timestamp.
> 
>  
> 
> So the question here is: how can I compute the time difference between 
> these two records in a single query?
> 
> Better yet: finding all the records that meet the first condition 
> (ignition off) and the immediately following records as to compute the 
> time difference. ;-)
> 
>  
> 
> Thanks in advance!
> 
>  
> 
> Pedro Doria Meunier
> 
> (351) 91 302 49 72 - (351) 96 247 99 12
> 
> MSN - pdoriam at hotmail.com <mailto:pdoriam at hotmail.com>
> 
> ICQ - 308-182-126
> 
> Skype: pdoriam
> 
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list