Home work?
I would start here http://www.dba-oracle.com/t_converting_rows_columns.htm