title: SQL variable group within another group
body: <p>I'm looking for a way to match a set of results from a larger list of other results, and count the number of matches. For example:</p>
  
  <p>I have a set of results</p>
  
  <pre><code>Result 1
  sub1
  sub2
  sub3
  
  Result 2
  sub1
  sub2
  sub3
  </code></pre>
  
  <p>I need to find how many times either set of the above results appears in a much larger data set of results below.</p>
  
  <pre><code>Result 1
  sub1
  sub2
  sub3
  
  Result 2
  sub1
  sub3
  sub4
  
  Result 2
  sub1
  sub2
  sub3
  
  Result 2
  sub1
  sub2
  sub3
  sub4
  </code></pre>
  
  <p>In the example above, Result 1 from the first set would match the first result in the second set, and Result 2 would match the final 2 results in the second set, because they contained all the sub results from the first set. So Result 1 would show a frequency count of 1, while Result 2 would show a frequency count of 2.</p>
  
  <p>I'm rather new with SQL, but would like to find a solution to the above problem.</p>
  
  <p>Sample Data from yesterday:</p>
  
  <pre><code>Group    Ad   Date
  A        1    7/14
  A        2    7/14
  A        3    7/14
  B        1    7/14
  B        2    7/14
  B        3    7/14
  B        4    7/14
  C        1    7/14
  D        1    7/14
  D        3    7/14
  D        4    7/14
  </code></pre>
  
  <p>I need to find out how many times Group A Ads 1-3 ran in the past week, but say on Monday Group A ran only ads 1 and 3. I don't want this result returned.  Tuesday Group A ran ads 1, 2, 3, 4. I WOULD want to know this result, Wednesday Group A had ads 1, 2, 3 run, this again I would want to know.</p>
  
  <pre><code>Group    Ad   Date
  A        1    7/09
  A        3    7/09
  A        1    7/10
  A        2    7/10
  A        3    7/10
  A        4    7/10
  A        1    7/14
  A        2    7/14
  A        3    7/14
  </code></pre>
  
  <p>So, given the example, I would expect to see this:</p>
  
  <pre><code>Group    Ad   Date
  A        1    7/10
  A        2    7/10
  A        3    7/10
  A        1    7/14
  A        2    7/14
  A        3    7/14
  </code></pre>