select
名称,
sum(decode(项目编码, '1', 得分)) 第一项得分,
sum(decode(项目编码, ‘2', 得分))第二项得分,
...,
sum(decode(项目编码, ’15', 得分))第十五项得分,
from
表名
group by 名称
select 名称,
sum(case when 项目编码=1 then 得分 else 0 end) as '第一项得分',
sum(case when 项目编码=2 then 得分 else 0 end) as '第二项得分',
...
sum(case when 项目编码=15 then 得分 else 0 end) as '第十五项得分'
from 表名
group by 名称
这样应该比较好理解,任何数据库都可以这样搞,decode函数mysql没有