0
My database is like this:
id | municipio_id | ano | populacao
1 | 0 | 2010 | 5000
2 | 0 | 2011 | 5000
I have the following query:
SELECT
case when ano = 2010 then populacao end a2010,
case when ano = 2011 then populacao end a2011
FROM populacao
where municipio_id = 0
The result comes out like this:
a2010 | a2011
5000 | null
null | 5000
I need the results to come out like this:
a2010 | a2011
5000 | 5000
How to do?
This answers your question? PIVOT - SELECT reversing row and column
– Sorack