문제

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
도움이 되었습니까?

해결책

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'))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top