第1个回答 2013-05-07
select id,
max(case when rn = 1 then op end ) op_1,
max(case wehn rn = 1 then result end ) result_1,
max(case when rn = 1 then else end ) else_1,
max(case when rn = 2 then op end ) op_2,
max(case wehn rn = 2 then result end ) result_2,
max(case when rn = 2 then else end ) else_2
from (
select a.*,
row_number() over(partition by id order by else) rn
from a)
group by id;