SELECT `num`,
SUM(type = 1) as `1`,
SUM(type = 2) as `2`,
SUM(type = 3) as `3`
FROM `your_table`
GROUP BY `num`
SELECT `num`,
SUM(type = 1) as `1`,
SUM(type = 2) as `2`,
SUM(type = 3) as `3`
FROM `your_table`
GROUP BY `num`