You did not mention the version of Oracle. If you are using Oracle 11g or above, the following example would get you close.
create table pivot_test (id number(1), month varchar2(3), value number(2));
insert into pivot_test values (1, 'Jun', 20);
insert into pivot_test values (1, 'Jul', 22);
insert into pivot_test values (1, 'Aug', 0);
insert into pivot_test values (1, 'Sep', 12);
insert into pivot_test values (2, 'Jun', 21);
insert into pivot_test values (2, 'Jul', 45);
commit;
select *
from (select id, month, sum(value) as value from pivot_test group by id, month)
pivot (SUM(value) for (month) in ('Jun', 'Jul', 'Aug', 'Sep'))
order by id
;
It yields the following result.
ID 'Jun' 'Jul' 'Aug' 'Sep'
---------- ---------- ---------- ---------- ----------
1 20 22 0 12
2 21 45