title: Returning data where dates are at least 7 days apart
body: <p>I'm interested in retaining only individuals in a Microsoft SQL Server query that have a value over a certain threshold on two separate dates. If the individuals have a score higher than 150 twice and the second date is at least 7 days after the first date, I would like to return their ID, the second date that their score was above 150, and the score on the second date.</p>
  
  <p>Here is the data:</p>
  
  <pre><code>SubjectID   DATE         Score
  001         01/11/2014   147
  001         02/11/2013   151
  002         02/10/2015   152
  003         08/12/2013   155
  002         01/31/2012   159
  003         07/19/2016   157
  </code></pre>
  
  <p>So I for the results, I would like to return the following:</p>
  
  <pre><code>SubjectID   DATE         Score
  002         02/10/2015   152
  003         07/19/2016   157
  </code></pre>
  
  <p>As per a previous question I asked, I am using the following code to return the second date:</p>
  
  <pre><code> SELECT *
      FROM Clinic a
      WHERE a.score &gt; 150 
            AND a.date IN (SELECT MAX(b.date) 
                           FROM Clinic b 
                           WHERE b.subjectId = a.subjectId 
                                  AND b.score &gt; 150)
  </code></pre>
  
  <p>I think I would need to add something like the following to the WHERE statement: </p>
  
  <pre><code>AND (b.date - a.date) &gt; 7;
  </code></pre>