I have a table in PostgreSQL like:
org_name | month_1 | month_2 | ... | month_12
---------------------------------------------
org1     |  20     |   30    | ... |  15
org2     |  34     |   27    | ... |  49
I need to transpose it to:
month  |  org1 | org2 
----------------------
   1   |   20  | 34
   2   |   30  | 27
..     |   ..  | ..
  12   |   15  | 49
I found next solution on stackoverflow:
SELECT
    *
FROM 
    (select org_name, monthes, value
    from my_table
    unpivot
    (
        value
        for monthes in (month_2, month_3, month_4, month_5, month_6, month_7, month_8, month_9, month_10, month_11, month_12)
    ) unpiv
    ) src
    pivot
    ( 
        sum(value)
        for org_name in ('org1', 'org2')
    ) piv
But it doesn't work with syntax error about 'for'. Where I'm wrong?
 
     
     
    