title: How to find the difference between two date cells of different rows in sql server 2012?
body: <p>I have a sql table with each record start and end time as shown in the picture. I am interested in finding difference between them. I found them by using datediff(second, starttime, endtime) but it gives the difference in values of the same rows. However I want to see if the next 'date/time' starts from where the previous row end 'date/time' finished or there is some gap for each row? I am indicating the sample cells in which I want to find the difference if any or 0. I want to find for the complete columns. Thanks</p>
  
  <p><img src="https://i.stack.imgur.com/kZZrw.png" alt="enter image description here"></p>