title: Calculate the sum of minutes in overlapping timeranges
body: <p>I need to calculate the sum of minutes of terms. Overlapping terms should not count multiple times.</p>
  
  <pre><code>Declare @Terms table (Start DATETIME, Finish DATETIME)
  INSERT INTO @Terms values
      ('2016-8-3 08:00','2016-8-3 09:00'),
      ('2016-8-3 09:00','2016-8-3 10:00'),
      ('2016-8-3 08:00','2016-8-3 09:30'),   -- overlapping term
      ('2016-8-3 11:00','2016-8-3 12:00')
  </code></pre>
  
  <p>The result from the data above should be 180 minutes (3 hours). What is the easiest and fastest way to to this?</p>