title: Query to calculate average time between successive events
body: <p>My question is about how to write an SQL query to calculate the average time between successive events.</p>
  
  <p>I have a small table:</p>
  
  <pre><code>event Name    |    Time
  
  stage 1       |    10:01
  stage 2       |    10:03
  stage 3       |    10:06
  stage 1       |    10:10
  stage 2       |    10:15
  stage 3       |    10:21
  stage 1       |    10:22
  stage 2       |    10:23
  stage 3       |    10:29
  </code></pre>
  
  <p>I want to build a query that get as an answer the average of the times between stage(i) and stage(i+1).</p>
  
  <p>For example,
  the average time between stage 2 and stage 3 is 5:</p>
  
  <pre><code>(3+6+6)/3 =  5
  </code></pre>