title: Use subquery in select statement in Tableau
body: <p>I have three tables with the following structures:
  1) patients (id, name)
  2) illnesses (id, name)
  3) patient_illnesses (patient_id, illness_id)</p>
  
  <p>In Tableau, I'd like to query for the illnesses that patients have for a select group of patients (for instance, those that do not have cancer).</p>
  
  <p>IN SQL, this would look like.</p>
  
  <pre><code>SELECT * FROM patients 
  INNER JOIN patient_illnesses ON patients.id = patient_illnesses.patient_id 
  INNER JOIN illnesses ON illnesses.id = patient_illnesses.illness_id 
  WHERE NOT patients.id NOT IN (
  SELECT patients.id FROM patients
  INNER JOIN patient_illnesses ON patients.id = patient_illnesses.patient_id 
  WHERE patient_illnesses.illness_id = 4 
  GROUP BY patients.id
  )
  </code></pre>
  
  <p>In this example, illness_id 4 refers to a specific illness, but I would like to be able to multiselect filter in Tableau on this.</p>
  
  <p>I'm able to accomplish this in Tableau with custom SQL, but I can't get the filter to work when I use custom SQL.</p>
  
  <p>Any thoughts?</p>