SQL count and distinct query
<p>I'm trying to build up a query that would count and distinct at the same time. This is the raw data</p>

<p><a href="http://i.stack.imgur.com/JMbyG.png" rel="nofollow">Raw Data</a></p>

<pre><code>+--------+---------+
| IntID  | ErrorID |
+--------+---------+
| ins001 |    1    |
| ins001 |    1    |
| ins001 |    2    |
| ins002 |    3    |
| ins002 |    5    |
| ins002 |    5    |
| ins003 |    4    |
| ins003 |    1    |
| ins003 |    1    |
+--------+---------+
</code></pre>

<p>What im trying to accomplish is a count for each error id for each distinct instrument id, as shown below:</p>

<p><a href="http://i.stack.imgur.com/cnBwP.png" rel="nofollow">What is expected</a></p>

<pre><code>+--------+-------------+-------------+-------------+-------------+-------------+
| IntID  | ErrorID=001 | ErrorID=002 | ErrorID=003 | ErrorID=004 | ErrorID=005 |
+--------+-------------+-------------+-------------+-------------+-------------+
| ins001 |      2      |      1      |      0      |      0      |      0      |
| ins002 |      0      |      0      |      1      |      0      |      2      |
| ins003 |      2      |      0      |      0      |      1      |      0      |
+--------+-------------+-------------+-------------+-------------+-------------+
</code></pre>

<p>Any advice or help is greatly appreciated. Thanks in advance</p>