title: How to group sums by weekday in MySQL?
body: <p>I have a table like this:  </p>
  
  <pre><code>id | timestamp  | type  
  -----------------------
  1    2010-11-20   A
  2    2010-11-20   A
  3    2010-11-20   B
  4    2010-11-21   A
  5    2010-11-21   C
  6    2010-11-27   B
  </code></pre>
  
  <p>and I need to count the rows for each type, grouped by weekday; like this:</p>
  
  <pre><code>weekday |  A  |  B  |  C 
  --------------------------
  5          2     2     0    -- the B column equals 2 because nov 20 and nov 27 are saturday
  6          1     0     1
  </code></pre>
  
  <p>What would be the simplest solution for this?<br>
  I don't mind using views, variables, subqueries, etc.</p>