title: Comparing multiple rows of data within a date range to create a new table in MS Access
body: <p>I'm a novice to SQL &amp; MS-Access, however I have a table of data in MS-Access that looks like:</p>
  
  <pre><code>ID | Start_Time | End_Time 
  1  | 1:00:00 PM | 1:00:30 PM
  2  | 2:15:10 PM | 2:15:50 PM
  3  | 2:15:30 PM | 2:18:40 PM
  4  | 2:17:00 PM | 2:17:30 PM
  5  | 2:45:10 PM | 3:03:10 PM
  </code></pre>
  
  <p>Each row is sequentially recorded into the database. I want to compare the start and end times of each and combine together rows that overlap. For instance, ID 1's <code>Start_Time</code> and <code>End_Time</code> do not overlap any other times in the table, therefore, it would get posted into the new table. However, ID 2 through 4 have <code>Start_Time</code>s and <code>End_Time</code>s that overlap with ID 2's <code>Start_Time</code> as <code>Start_Time</code> of the group and ID 3's <code>End_Time</code> as the <code>End_Time</code> of the group ID 2 through 4.</p>
  
  <p>The end result would be a new table that should look like:</p>
  
  <pre><code>ID | Start_Time | End_Time   | Duration_seconds
  1  | 1:00:00 PM | 1:00:30 PM | 30
  2  | 2:15:10 PM | 2:18:40 PM | 210
  3  | 2:45:10 PM | 3:03:10 PM | 1080
  </code></pre>
  
  <p>How can I do this in SQL/MS-Access?</p>
  
  <p>Thank you!!</p>