title: Need to handle the rows that don't get picked
body: <p>In the following, we are picking all patients who saw a Dr. but we remove 4 Doctors from this, because they are no longer in our facility. The problem here is that if a patient has ONLY seen from these 4 Doctors, they will not get selected. In fact, we want to assign them to <code>b.Appt_resource_id = 142</code>. How would i be able to also include such patients? The data we are getting from this sql looks like this:</p>
  
  <pre><code>    110811      737470                  Mirta  AVostaquishpe        19  
  
      102028      664770                  Brune  Alexgdre     19  
  
      70038       361830                  Pala  Avtila        19  
  
      44684       112740                  Nani  Verez     19  
  
      71939       382620                  Alex  Voachim       19  
  </code></pre>
  
  <p>You can see that each patient is assigned to a Doctor via this b.Appt_Resource_ID. but this leaves out patients who have ONLY seen from the 4 Doctors who left the facility by now. How to included them and assign them to b.appt_resource_id= 142.</p>
  
  <pre><code>SELECT DISTINCT
      A.Patient_id,
      P.Patient_name,
      P.Patient_Last_Name,
      A.Patient_number,
      b.Appt_resource_id,
      b.appt_resource_descr 
  FROM
      [PM].[vwGenPatApptInfo] A
  INNER JOIN 
  (
      SELECT TOP 100 PERCENT
          patient_id,
          Appt_resource_id,
          appt_resource_descr, 
          COUNT(Appt_resource_id) AS DR_count,
          ROW_NUMBER() OVER (PARTITION BY patient_id ORDER BY COUNT(*) DESC) AS seqnum
      FROM
          [PM].[vwGenPatApptInfo]
      WHERE
          Patient_ID IS NOT NULL AND
          Appt_Sched_Department_ID = 2 AND
          Appt_resource_id not IN (115, 123, 94, 109)
      GROUP BY
          patient_id,
          Appt_resource_id,
          appt_resource_descr
      ORDER BY
          patient_id,
          seqnum 
      ) B
      ON B.Patient_ID = A.Patient_ID  
      AND B.seqnum = 1 
  INNER JOIN
      [PM].[vwGenPatInfo] P 
      ON A.Patient_id = P.Patient_id
  WHERE
      A.Appt_Cancelled_Date IS NULL AND
      A.Appt_Noshow_date IS NULL
  </code></pre>