56,678
社区成员
发帖
与我相关
我的任务
分享
select code,
max(case row_id when 1 then NAME end) as NAME1,
max(case row_id when 1 then VALUE end) as VALUE1,
max(case row_id when 2 then NAME end) as NAME2,
max(case row_id when 2 then VALUE end) as VALUE2,
max(case row_id when 3 then NAME end) as NAME3,
max(case row_id when 3 then VALUE end) as VALUE3,
max(case row_id when 4 then NAME end) as NAME4,
max(case row_id when 4 then VALUE end) as VALUE4,
max(case row_id when 6 then NAME end) as NAME5,
max(case row_id when 6 then VALUE end) as VALUE5
from(
select *,(select count(*) from t t1 where t1.code=t.code and t1.id <=t.id) as row_id from t order by code, id
) data
group by code