DomingoSL
DomingoSL

Reputation: 15494

General MySQL query compostion

In a table like this one: enter image description here

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

Answers (1)

Buttle Butkus
Buttle Butkus

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

Related Questions