I have a table that looks something like this:
+------+----------+----------+--------+
| id | team | match | score |
+------+----------+----------+--------+
| 1 | 1 | 1 | 10 |
| 2 | 2 | 1 | 5 |
| 3 | 1 | 1 | 5 |
| 4 | 1 | 2 | 6 |
| 5 | 2 | 1 | 4 |
+------+----------+----------+--------+
I need to calculate SUM() of all the scores for each individual match and team, I know how to calculate the sum…
SELECT SUM(score) AS team_a_score WHERE `match`='1'
I’d expect something like this…
+----------------+
| team_a_score |
+----------------+
| 24 |
+----------------+
But what I actually need to happen is to get the score for team 1 and 2 separately so it would be more like this…
+----------------+----------------+
| team_a_score | team_b_score |
+----------------+----------------+
| 15 | 9 |
+----------------+----------------+
Hope this is clear enough
How about this
the result would not be in columns (as described in your questions) but in rows each one with the team number and the total score