You want aggregation:
SELECT SUM(case when ano = 2010 then populacao end) as a2010,
SUM(case when ano = 2011 then populacao end) as a2011
FROM populacao
WHERE municipio_id = 0;
If you want it for all municipios, then use GROUP BY
:
SELECT municipio_id,
SUM(case when ano = 2010 then populacao end) as a2010,
SUM(case when ano = 2011 then populacao end) as a2011
FROM populacao
GROUP BY municipio_id;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…