Comparing sequential rows in a result - Mailing list pgsql-sql

From Murray Long
Subject Comparing sequential rows in a result
Date
Msg-id 56acee400810290201x68cbc8s1bf9231a27999655@mail.gmail.com
Whole thread Raw
Responses Re: Comparing sequential rows in a result
List pgsql-sql
I'm relatively new to SQL, and am frequently running into the same problem, How do I compare different rows in a
result?<br/><br />for example:<br />If I have a table of  events consisting of a time stamp and the event type:<br
/><br/>timestamp,     event_type<br />12:00                 a<br />12:10                 b<br />12:20                
a<br/>...<br /><br />I'd like to be able to select all the 'a' type events and calculate the time since the previous
'a'event, to get:<br /> timestamp,     event_type,     time_since_last<br /> 12:00                
a                            0:20<br /> 12:20                 a                             NULL<br /><br />What's the
bestway to to accomplish this? <br /><br /><br />Thanks in advance,<br />Murray<br /><br /><br /><br /> 

pgsql-sql by date:

Previous
From: Michael Higgins
Date:
Subject: join table?
Next
From: "Murray Long"
Date:
Subject: Re: Comparing sequential rows in a result