Comparing sequential rows in a result

Поиск
Список
Период
Сортировка
От Murray Long
Тема Comparing sequential rows in a result
Дата
Msg-id 56acee400810290201x68cbc8s1bf9231a27999655@mail.gmail.com
обсуждение исходный текст
Ответы Re: Comparing sequential rows in a result
Список 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 по дате отправления:

Предыдущее
От: Michael Higgins
Дата:
Сообщение: join table?
Следующее
От: "Murray Long"
Дата:
Сообщение: Re: Comparing sequential rows in a result