• Here's a bit of code to get you started:-

    SELECT

    ID,

    TimeStamp,

    LAG(TimeStamp,1) OVER (ORDER BY ID DESC),

    DATEDIFF(HOUR, TimeStamp, LAG(TimeStamp,1) OVER (ORDER BY ID DESC))

    FROM [dbo].[RunningTime]

    It uses the LAG function to get the previous value and then uses the DATEDIFF function to compare the two.