My Data Set looks like this:
The Output given in column D is derived as follows:
Output against index 2 : TimeStamp in Index 3 - TimeStamp in Index 2
Output against index 6 : TimeStamp in Index 10 - TimeStamp in Index 6
Output against index 12 : TimeStamp in Index 15 - TimeStamp in Index 12
DataSet MySQL V2012
create table #temp11 (Index# int, TimeStamp# Datetime, Alarm int)
insert into #temp11 values
(1, '10/6/2019 00:08:01', 0),
(2, '10/6/2019 00:08:13' ,1),
(3, '10/6/2019 00:08:15' ,1),
(4, '10/6/2019 00:10:47' ,0),
(5, '10/6/2019 00:10:58' ,0),
(6, '10/6/2019 00:10:59' ,1),
(7, '10/6/2019 00:11:00' ,1),
(8, '10/6/2019 00:11:01' ,1),
(9, '10/6/2019 00:11:02' ,1),
(10, '10/6/2019 00:11:03' ,1),
(11, '10/6/2019 00:11:04' ,0),
(12, '10/6/2019 00:11:05' ,1),
(13, '10/6/2019 00:11:06' ,1),
(14, '10/6/2019 00:11:07' ,1),
(15,'10/6/2019 00:11:15' ,1)
TIA