title: Condense Time Periods with SQL
body: <p>I have a large data set which for the purpose of this question has 3 fields:</p>
  
  <ul>
  <li>Group Identifier</li>
  <li>From Date</li>
  <li>To Date</li>
  </ul>
  
  <p>On any given row the <code>From Date</code> will always be less than the <code>To Date</code> but within each group the time periods (which are in no particular order) represented by the date pairs could overlap, be contained one within another, or even be identical. </p>
  
  <p>What I'd like to end up with is a query that condenses the results for each group down to just the continuous periods. For example a group that looks like this:</p>
  
  <pre><code>| Group ID | From Date  | To Date    |
  --------------------------------------
  | A        | 01/01/2012 | 12/31/2012 |
  | A        | 12/01/2013 | 11/30/2014 |
  | A        | 01/01/2015 | 12/31/2015 |
  | A        | 01/01/2015 | 12/31/2015 |
  | A        | 02/01/2015 | 03/31/2015 |
  | A        | 01/01/2013 | 12/31/2013 |
  </code></pre>
  
  <p>Would result in this:</p>
  
  <pre><code>| Group ID | From Date  | To Date    |
  --------------------------------------
  | A        | 01/01/2012 | 11/30/2014 |
  | A        | 01/01/2015 | 12/31/2015 |
  </code></pre>
  
  <p>I've read a number of articles on date packing but I can't quite figure out how to apply that to my data set.</p>
  
  <p>How can construct a query that would give me those results?</p>