add batch remove batch split batch comment selection show hidden batches hide batch highlight batch
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE MyTable(DateTime datetime, Events varchar(255), CF_ID INT)

INSERT INTO MyTable (DateTime,Events,CF_ID) VALUES
('04/11/2022 08:00:09' , 'Login', 521 ),
('04/11/2022 08:01:29' , 'Inxt', 426 ),
('04/11/2022 08:23:57' , 'Rgal', 731 ),
('04/11/2022 08:24:08' , 'hold', 78 )




4 rows affected
WITH CTE AS
(SELECT
DateTime,
Events,
CF_ID,
(DATEPART(SECOND, DateTime) +
60 * DATEPART(MINUTE, DateTime) +
3600 * DATEPART(HOUR, DateTime))
AS ConvertToSeconds
FROM MyTable)

SELECT
DateTime,
Events,
CF_ID,
LEAD(ConvertToSeconds) OVER( ORDER BY DateTime) - ConvertToSeconds

FROM CTE
ORDER BY DateTime
DateTime Events CF_ID (No column name)
2022-04-11 08:00:09.000 Login 521 80
2022-04-11 08:01:29.000 Inxt 426 1348
2022-04-11 08:23:57.000 Rgal 731 11
2022-04-11 08:24:08.000 hold 78 null