title: Count maximum continuous months across multiple rows
body: <p>I am attempting to count the maximum number of continuous months in a table across multiple rows of start dates end dates.  The date ranges do not need to be completely continuous, only the months need to be continuous.  For example, if a customer has a date range of 01/01/2012 - 06/01/2012, and 07/01/2012 - 08/31/2012, then we count June and July, resulting in 8 continuous months. </p>
  
  <p>Sample data is below.</p>
  
  <p><strong>Base Table</strong>
  <code>
  CustomerID     StartDate      EndDate
  ----------     ----------     ----------
  1001           01/01/2012     06/30/2012
  1001           07/01/2012     08/31/2012
  1001           01/01/2013     07/31/2013
  1002           01/01/2012     06/01/2012
  1002           07/01/2012     08/31/2012
  1003           01/01/2012     05/31/2012
  1003           07/01/2012     08/31/2012
  1004           01/01/2012     02/28/2012
  1004           03/01/2012     07/31/2012
  1004           08/01/2012     08/31/2012</code></p>
  
  <p><strong>Results</strong>
  <code>
  CustomerID     MaxContinuous
  ----------     -------------
  1001           8
  1002           8
  1003           5
  1004           8</code></p>
  
  <p>It should be possible to create a sub-table with every single month involved with a loop, and then loop through that table looking for continuous months, however that involves two loops, which I would prefer to avoid.</p>