title: Counting Distinct Months with Multiple records per month
body: <p>My data looks like this:</p>
  
  <pre><code>Code    Date
  123     1/2/2016
  123     1/4/2016 
  123     1/4/2016
  123     2/5/2016
  456     1/2/2016
  456     1/3/2016
  456     2/7/2016
  789     1/7/2016
  789     1/8/2016
  789     3/7/2016
  789     3/15/2016
  </code></pre>
  
  <p>I am looking for a distinct count of months grouped by the code.</p>
  
  <p>So the results would look something like this</p>
  
  <pre><code>Code     Jan2016      Feb2016      Mar2016
  123         1           1            0
  456         1           1            0
  789         1           0            1
  </code></pre>
  
  <p>I feel like I may be overcomplicating my code.</p>
  
  <p>So far I have</p>
  
  <pre><code>SELECT
      p.code
      ,SUM(CASE WHEN p.date BETWEEN '11/1/2010' AND '11/30/2010' 
      THEN 1 ELSE 0 END) AS 'Nov2010'
      FROM table
      Group By p.code
  </code></pre>
  
  <p>But that is pulling in all records from Nov2010, when I just need to know if this exists</p>