我有一个看起来像这样的表:
+------+----------+----------+--------+
| id | team | match | score |
+------+----------+----------+--------+
| 1 | 1 | 1 | 10 |
| 2 | 2 | 1 | 5 |
| 3 | 1 | 1 | 5 |
| 4 | 1 | 2 | 6 |
| 5 | 2 | 1 | 4 |
+------+----------+----------+--------+
我需要计算SUM()
每场比赛和球队的所有分数,我知道如何计算总和......
SELECT SUM(score) AS team_a_score WHERE `match`='1'
我期待这样的事情......
+----------------+
| team_a_score |
+----------------+
| 24 |
+----------------+
但我真正需要做的是分别获得第 1 队和第 2 队的分数,所以它会更像这样......
+----------------+----------------+
| team_a_score | team_b_score |
+----------------+----------------+
| 15 | 9 |
+----------------+----------------+
希望这足够清楚