Reputation: 15494
In a table like this one:
Is there a way to retrieve directly using a MySQL query an array with the total for each year of men and women for each country?
For example:
cittadinanza 1987 1988 1990 ...
Afghanistan 13 13 12 ...
Albania 22 20 19 ...
... .. .. .. ...
Upvotes: 0
Views: 42
Reputation: 9456
Yes, you just need to GROUP BY country.
SELECT `citidinanza`, SUM(`1987`) as `1987`, SUM( `1988`) AS `1988` FROM `table` GROUP BY `citidinanza`
Upvotes: 1