[英]How to simplify the result of repeated columns after making a COUNT query in MySQL?
[英]How to count result from two columns in mysql
我有一个预测表,包括homescore和awayscore。 我想输出所有不同的预测以及每个预测有多少个实例。
matchid homescore awayscore
1 1 2
1 1 0
1 9 3
1 2 0
1 1 2
1 1 0
2 3 2
2 2 2
...
我希望它为matchid 1输出一个这样的表:
result predictions
1-2 2
1-0 2
9-3 1
2-0 1
SELECT
CONCAT(homescore, '-', awayscore) as result,
COUNT(*) as predictions
FROM table
WHERE matched = 1
GROUP BY CONCAT(homescore, '-', awayscore);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.