title: Count values in a table taken from a list in SQL
body: <p>I Have one list that is instantiated by the following:</p>
  
  <pre><code>SELECT 
  chklRefTo
  FROM CSART.DBO.tblMaintenance
  </code></pre>
  
  <p>and returns the following:</p>
  
  <pre><code>chklRefTo
  ----------
  SRH
  STI
  GP/Walk-in
  ED/UCC
  Other
  </code></pre>
  
  <p>and another column of values</p>
  
  <pre><code>Ref to
  -------
  STI
  STI,GP/Walk-in,ED/UCC
  GP/Walk-in,ED/UCC
  SRH,STI,ED/UCC
  STI,Other
  </code></pre>
  
  <p>That is instantiated by this:</p>
  
  <pre><code>SELECT
  ReferredTo AS "Reason Not Admitted"
  FROM CSART.DBO.tblPhoneConsult
  WHERE ReferredTo != '' AND ReferredTo IS NOT NULL
  </code></pre>
  
  <p>For each value in the first list, I need a count of the number of times each value appears in the second list. Ideally, the result of the query would look something like the below:</p>
  
  <pre><code>Ref    Num
  -----------
  STI  | 3
  SRH  | 1
  Other| 1
  </code></pre>
  
  <p>I haven't been having much luck trying to work through this problem so any help or advice would be greatly appreciated. Thank you.</p>