I have a table like this,
+----------------+
| id | name|type |
+----+-----+-----+
| 1 | J | A |
| 2 | S | A |
| 3 | S | B |
| 4 | S | B |
| 5 | J | B |
| 6 | J | C |
+----+-----+-----+
id is Primary Key, name's value are not certain, but type's value can only be A, B or C. Want to build a MySql view, which means a SELECT, to output following table, which count different types by name.
+--------------------------------------------------+
| name| countOfTypeA | countOfTypeB | countOfTypeC |
+--------------------------------------------------+
| J | 1 | 1 | 1 |
+--------------------------------------------------+
| S | 1 | 2 | 0 |
+--------------------------------------------------+
Tried "Group by name, type" but it output types in rows not in columns. Please help.