My data looks like this:

```
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

```

I am looking for a distinct count of months grouped by the code.

So the results would look something like this

```
Code     Jan2016      Feb2016      Mar2016
123         1           1            0
456         1           1            0
789         1           0            1

```

I feel like I may be overcomplicating my code.

So far I have

```
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

```

But that is pulling in all records from Nov2010, when I just need to know if this exists