Data
id date
2380 10/30/12 09:00:00
2380 10/30/12 09:05:00
2380 10/30/12 09:10:00
2380 10/30/12 09:15:00
2381 10/30/12 10:00:00
2381 10/30/12 10:05:00
2381 10/30/12 10:10:00
2381 10/30/12 10:15:00
2382 10/30/12 11:00:00
2382 10/30/12 11:05:00
2382 10/30/12 10:10:00
2382 10/30/12 10:15:00
and I want the following solution
id date duration
2380 10/30/12 09:00:00 00:00:00
2380 10/30/12 09:05:00 00:05:00
2380 10/30/12 09:10:00 00:10:00
2380 10/30/12 09:15:00 00:15:00
2381 10/30/12 10:00:00 00:00:00
2381 10/30/12 10:05:00 00:05:00
2381 10/30/12 10:10:00 00:10:00
2381 10/30/12 10:15:00 00:15:00
2382 10/30/12 11:00:00 00:00:00
2382 10/30/12 11:05:00 00:05:00
2382 10/30/12 10:10:00 00:10:00
2382 10/30/12 10:15:00 00:10:00
I have tried to understand the logic behind the following thread but it's difficult to understand.
Substract date from previous row by group (using R)
select id, date, date - (select min(date) from date group by id) as duration
from date
Closest I have got is for one id.