title: How to calculate average time Postgresql
body: <p>i'm trying to execute a query that would give me the average time of a Race knowing that my table is structured as follow</p>
  
  <pre><code>RunnerID,   State,   Timestamp_race
  R1          start     2017-04-11 12:15:15.722415
  R2          start     2017-04-11 13:15:15.722415
  R1          finish    2017-04-11 15:15:15.722415
  R1          finish    2017-04-11 17:15:15.722415
  </code></pre>
  
  <p>the runners starts at different times and end at different times the idea is to calculate the average time for the whole race</p>