title: Exclude Sub Intervals from parent interval in postgresql
body: <p>I have 2 tables:</p>
  <p><strong>Table 1 has Users Session Data</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">user_id</th>
  <th style="text-align: left;">login_time</th>
  <th style="text-align: left;">logout_time</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">a1</td>
  <td style="text-align: left;">2022-01-10 09:02:54.927</td>
  <td style="text-align: left;">2022-01-10 18:07:42.876</td>
  </tr>
  <tr>
  <td style="text-align: left;">s1</td>
  <td style="text-align: left;">2022-01-10 09:07:51.104</td>
  <td style="text-align: left;">2022-01-10 18:44:23.053</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>Table 2 has Users Chat Data</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">user_id</th>
  <th style="text-align: left;">user_connected_time</th>
  <th style="text-align: left;">user_disconnected_time</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">a1</td>
  <td style="text-align: left;">2022-02-10 13:10:49.975</td>
  <td style="text-align: left;">2022-02-10 13:25:22.26</td>
  </tr>
  <tr>
  <td style="text-align: left;">a1</td>
  <td style="text-align: left;">2022-02-10 17:35:12.34</td>
  <td style="text-align: left;">2022-02-10 17:55:05.283</td>
  </tr>
  <tr>
  <td style="text-align: left;">s1</td>
  <td style="text-align: left;">2022-02-15 14:08:34.39</td>
  <td style="text-align: left;">2022-02-15 14:09:28.627</td>
  </tr>
  <tr>
  <td style="text-align: left;">s1</td>
  <td style="text-align: left;">2022-02-15 14:00:47.261</td>
  <td style="text-align: left;">2022-02-15 14:16:29.339</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I need the agent ideal time i.e. when the agent wasn't connected on any chat.</p>
  <p>Expected output</p>
  <p>Agent Ideal Duration</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">agent_ideal_duration</th>
  <th style="text-align: left;">agent_id</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">08:44:55.006</td>
  <td style="text-align: left;">a1</td>
  </tr>
  <tr>
  <td style="text-align: left;">09:20:49.871</td>
  <td style="text-align: left;">s1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Overlapping chat duration is removed from Agent's s1 ideal time.</p>
  <p><strong>Note: 1 agent can take multiple chats at a time.</strong></p>