I want to use a query to get this result:
Postid(20) ---> 4 type(0) et 2 type(1)
Postid(21) ---> 3 type(0) et 3 type(1).
From this table:
id | userid | postid | type
1 | 465 | 20 | 0
2 | 465 | 21 | 1
3 | 466 | 20 | 1
4 | 466 | 21 | 0
5 | 467 | 20 | 0
6 | 467 | 21 | 0
7 | 468 | 20 | 1
8 | 468 | 21 | 1
9 | 469 | 20 | 0
10 | 469 | 21 | 1
11 | 470 | 20 | 0
12 | 470 | 21 | 0
I think I have to use GROUP BY
, I tried it but I get no results.
How can I achieve that result?