You did not state what version of Oracle you are using but if you are using Oracle 11g+, then you can transform this data into columns using the PIVOT
function:
select id,
C1,
C2,
column_data
from
(
select id, value, column_data,
row_number() over(partition by id order by id, value) rn
from yourtable
)
pivot
(
max(value)
for rn in ('1' as C1, '2' as C2)
)
order by id
See SQL Fiddle with Demo.
Prior to Oracle 11g, you could use an aggregate function with a CASE
expression to transform the rows into columns:
select id,
max(case when rn = 1 then value end) C1,
max(case when rn = 2 then value end) C2,
column_data
from
(
select id, value, column_data,
row_number() over(partition by id order by id, value) rn
from yourtable
)
group by id, column_data
order by id
See SQL Fiddle with Demo
The result of both queries is:
| ID | C1 | C2 | COLUMN_DATA |
------------------------------
| 1 | a | b | DATA1 |
| 2 | c | x | DATA2 |
| 3 | y | z | DATA3 |