title: How to get session duration in Standard SQL (BigQuery)
body: <p>I have the following table (table name is chats) and I would like to get the session duration for each contact and also the average session duration overall.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Owner</th>
  <th>timestamp</th>
  <th>inbound_timestamp</th>
  <th>outbound_timestamp</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>21766666666</td>
  <td>2021-03-09T06:55:06</td>
  <td>2021-03-09T06:55:04</td>
  <td>2021-03-09T06:55:06</td>
  </tr>
  <tr>
  <td>21766666666</td>
  <td>2021-03-09T12:36:08</td>
  <td>2021-03-09T12:36:05</td>
  <td>2021-03-09T12:36:08</td>
  </tr>
  <tr>
  <td>21766666666</td>
  <td>2021-03-09T17:54:09</td>
  <td>2021-03-09T17:54:06</td>
  <td>2021-03-09T17:54:09</td>
  </tr>
  <tr>
  <td>21722222222</td>
  <td>2021-04-16T12:41:34</td>
  <td>2021-04-16T12:41:33</td>
  <td>2021-04-16T12:41:34</td>
  </tr>
  <tr>
  <td>21722222222</td>
  <td>2021-04-16T12:42:48</td>
  <td>2021-04-16T12:42:33</td>
  <td>2021-04-16T12:42:48</td>
  </tr>
  <tr>
  <td>21722222222</td>
  <td>2021-04-16T12:43:39</td>
  <td>2021-04-16T12:43:30</td>
  <td>2021-04-16T12:43:39</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>Context:</strong></p>
  <p>The application that owns this records is a bot. From row one, contact 21766666666 sends a message to the bot at inbound_timestamp(2021-03-09T06:55:04), the bot replies at outbound_timestamp (2021-03-09T06:55:06) and the outboump is saved as timestamp.
  Same user replies again second row and third row.
  Rows 4,5 and 6 are from a different user.</p>
  <p>I'd like to be able to have a table which shows each user's average session time per day <strong>AND</strong> the total average session time per day. <strong>By session time I mean how long each user spent on the app (first inbound_timestamp - last outbound_timestamp)</strong></p>
  <p>Is this possible from the data I have.</p>