I have a table like this:
num | type
-----+------
123 | 3
123 | 2
123 | 3
123 | 2
124 | 3
124 | 1
124 | 3
124 | 3
I want to group by the num column, and have a column counting each distinct type (I know all the possible values here in advance). So I would get:
num | 1 | 2 | 3
-----+---+---+---
123 | 0 | 2 | 2
124 | 1 | 0 | 3
Is this possible with SQL? I am using MySql.