Please refer the db table image.

![enter image description here](https://i.stack.imgur.com/hyztg.jpg)

I want to count type with value 'Q' for each user id. I am confused either whatever I have written is correct or not.

```
"SELECT COUNT(type),userid FROM '$db_prefix'posts WHERE type=Q GROUP BY userid";

```

So where it will display total number of Q for x user id like below :

```
userid 1 has 25 Q
userid 2 has 11 Q
....

```

Same way for A and C but I think if I will get for Q than it will work in the same way for A and C.