Re: [SQL] Comparing sequential rows in a result

2008-10-29 Thread Murray Long
Here's one solution: create temp sequence tsec; create temp table ttab as select nextval('tsec'), * from (select * from events where event_type='a' order by timestamp desc) as troz; select ttab.*, ttab2.timestamp-ttab.timestamp from ttab join ttab as ttab2 on ttab2.nextval = ttab.nextval+1; This

[SQL] Comparing sequential rows in a result

2008-10-29 Thread Murray Long
I'm relatively new to SQL, and am frequently running into the same problem, How do I compare different rows in a result? for example: If I have a table of events consisting of a time stamp and the event type: timestamp, event_type 12:00 a 12:10 b 12:20