title: Select every second record then determine earliest date
body: <p>I have table that looks like the following</p>
  <p><a href="https://i.stack.imgur.com/pgtHD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pgtHD.jpg" alt="enter image description here" /></a></p>
  <p>I have to select every second record per PatientID that would give the following result (my last query returns this result)</p>
  <p><a href="https://i.stack.imgur.com/Jo7w4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jo7w4.png" alt="enter image description here" /></a></p>
  <p>I then have to select the record with the oldest date which would be the following (this is the end result I want)</p>
  <p><a href="https://i.stack.imgur.com/ufG4a.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ufG4a.png" alt="enter image description here" /></a></p>
  <p>What I have done so far: I have a CTE that gets all the data I need</p>
  <pre><code>WITH cte
  AS 
  (
      SELECT visit.PatientTreatmentVisitID, mat.PatientMatchID,pat.PatientID,visit.RegimenDate AS VisitDate, 
                          ROW_NUMBER() OVER(PARTITION BY mat.PatientMatchID, pat.PatientID ORDER BY visit.VisitDate ASC) AS RowNumber
      FROM tblPatient pat INNER JOIN tblPatientMatch mat ON mat.PatientID = pat.PatientID
      LEFT JOIN tblPatientTreatmentVisit visit ON visit.PatientID = pat.PatientID
  )
  </code></pre>
  <p>I then write a query against the CTE but so far I can only return the second row for each patientID</p>
  <pre><code>SELECT *
  FROM 
  (
      SELECT PatientTreatmentVisitID,PatientMatchID,PatientID, VisitDate,  RowNumber FROM cte    
  ) as X
  WHERE RowNumber = 2 
  </code></pre>
  <p>How do I return the record with the oldest date only? Is there perhaps a MIN() function that I could be including somewhere?</p>