开发者

Grouping amounts of data together and creating a on-the-fly amt column

I have a mysql database like this:

id - join_id - bool
1 - 32 - 1
2 - 32 - 0
3 - 32 - 1
4 - 32 - 1

I would like to query this:

join_id - bool (- amount)
32 - 1 - 3 (aka there are 3 instances where the join_id and bool are 32 and 1);
32 - 0 - 1 (aka there is 1 instances where the join_id and boo开发者_StackOverflowl are 32 and 0);

Any key words, or names would really helpful.


This is what you are looking for I think:

SELECT join_id, bool, COUNT(id) AS amount FROM mytable GROUP BY join_id,bool
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜