Given this table.
+----+-------+-------+
| id | color | grain | 
+----+-------+-------+
|  1 |   A   |   B   |
|  1 |   A   |   B   |
|  1 |   A   |   B   |
|  2 |   B   |   X   |
|  2 |   B   |   X   |
|  2 |   B   |   Z   |
|  2 |   E   |   E   |
|  3 |   A   |   C   |
|  3 |   A   |   B   |
|  3 |   A   |   B   |
+----+-------+-------+
What would be the MySQL query to produce the following result. I need to count the number of unique occurrences of color/grain combination within each id.
+----+-------+-------+-------------------+
| id | color | grain | color/grain count |
+----+-------+-------+-------------------+
|  1 |   A   |   B   |         1         |
|  2 |   B   |   X   |         3         |
|  2 |   B   |   Z   |         3         |
|  2 |   E   |   E   |         3         |
|  3 |   A   |   C   |         2         |
|  3 |   A   |   B   |         2         |
+----+-------+-------+-------------------+
This is my current query, but it does not produce the count I am looking for. The count is for the occurrences of the group by clause, not the unique occurrences within id.
select id,color,grain,count(id)
  from table
group by id,color,grain
order by id;
 
    