title: Calculate Time Difference of two consecutive rows in one column of a table in SQL Server
body: <p>I have a query like </p>
  
  <pre><code>table1
  ____________________________________________________________________
  UniqueID   TicketNumber   Action                    Date
  --------------------------------------------------------------------
   1         123456         Dependency Occured        3/25/2015 7:40:39 AM
   2         123456         Tech Support requested    3/25/2015 10:00:47 AM
   3         123456         Tech Support Given        3/25/2015 11:30:40 AM
   4         123456         Dependency Occured        3/25/2015 02:30:40 PM
   5         123456         Tech Support Given        3/25/2015 03:30:40 PM
  </code></pre>
  
  <p>Here for the same <strong>TicketNumber</strong> there are various actions performed at a given time. Now I have to find total time  '<em>Dependency Occured</em>'.
  So the Date of Action, for <em>Dependency Occurred</em> has to be subtracted from the row just below it, from that I have to calculate total time Dependency has occurred.
  Like 1st row - 2nd row gives <strong>2 hrs 20 mins.</strong>
  and 4th row - 5th row gives <strong>1 hour.</strong> 
  So total dependency occurred is <strong>3 Hrs 20 Mins.</strong></p>
  
  <p>Thanks in advance.</p>