title: Gaps and Islands ? Or Not?
body: <p>I have the following table:</p>
  
  <pre><code>;with data as (
  select '508325'  as [customer], 'G61' as [demo_given],
          cast('2015-1-1' as date) as [date_of_demo]
  union all select '508325', 'G61', cast('2015-3-1' as date) 
  union all select '508325', 'G61',cast('2015-3-15' as date)
  union all select '508325', 'G61',cast('2015-3-16' as date)
  union all select '508325', 'G61',cast('2015-3-17' as date)
  union all select '508325', 'G61',cast('2015-6-1' as date)
  union all select '508325', 'G61',cast('2015-8-1' as date)
  union all select '508325', 'G61',cast('2015-9-1' as date)
  union all select '508325', 'G61',cast('2015-9-1' as date)
  union all select '508325', 'G61',cast('2015-12-1' as date)
  )
  </code></pre>
  
  <p>Per customer there may be only 3 demos given in a 4 month period.
  The first period starts counting at the first demo given and ends 4 months later. </p>
  
  <p>If the number of demos in that period exceeds 3 I need the dates of the demos 4 and later in that 4 month period.
  (that would be <code>2015-3-16</code> and <code>2015-3-17</code> in this example)</p>
  
  <p>The next period starts at the date of the first demo given after the first four months. So I need to count the number of demos in the period <code>2015-6-1</code> up until <code>2015-9-30</code> and return the dates of the eventual 'surplus' demos given in that period.</p>
  
  <p>How would I go about doing this?</p>