Pergunta

I have a simple table that has data like the following

     FiscalYear             Month               Value
      2013                   01                  10
      2013                   02                  15

....

      2014                   01                  15
      2014                   02                  20

using Oracle(11g) Pivot query is it possible to get something like this?

     Month   2013   2014
      01      10     15
      02      15     20
Foi útil?

Solução

SELECT month, value_2013, value_2014
FROM   (SELECT fiscalyear, month, value FROM your_table) 
PIVOT (SUM (value) AS value                                                         
       FOR (fiscal_year)                                                         
       IN ('2013', '2014'))
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top