title: Need results restricted while including evaluation of values excluded
body: <p>Let's say I have the following tables:</p>
  <pre><code>donor.id
  donations.date
  Procedures.code (can be 'PLT', 'WB', or 'CCP')
  </code></pre>
  <p>What I want is to return, for the last 18 months, all donors who have done a PLT procedure with the earliest PLT donation date in the specified date range. However, I also need to include an evaluation, based on that date range, to mark (yes/no) as to whether that donor donated any WB or CCP procedure.</p>
  <pre><code>SELECT
  donor.id, 
  donations.date, 
  procedures.code, 
  CASE WHEN procedures.code IN 'WB' THEN 'yes' ELSE 'no' END as 'Prior WB?&quot;, 
  CASE WHEN procedures.code IN 'CCP' THEN 'yes' ELSE 'no' END as 'Prior CCP?&quot;
  FROM donations
  INNER JOIN donor ON donations.id = donor.id
  LEFT JOIN procedures on donations.procedure_id = procedures.id
  WHERE procedures.code IN 'PLT' AND donations.date &gt;= curdate() - interval (dayofmonth(curdate()) - 1) day - interval 18 month
  GROUP BY donor.id
  ORDER BY donations.date ASC
  </code></pre>
  <p>This gives me only PLT donors with their earliest PLT donation date given for the past 18 months (GOOD!)
  HOWEVER, both of those CASE WHEN parts are not working (obviously since my WHERE excludes WB and PLT). I've tried several other ways to get this to work (having, exists, sub queries and I either get no results or the results include donors that haven't given a PLT donation at all.</p>
  <p>Just need hep thinking this through how to include all procedures for evaluation but only return the donors that have given a PLT donation in that time frame.</p>