首页 > 代码库 > decode 横竖转换 2

decode 横竖转换 2

技术分享

select sno,
nvl(to_char(sum(decode(cno,‘c001‘,score))),‘-‘) c001,
nvl(to_char(sum(decode(cno,‘c002‘,score))),‘-‘) c002,
nvl(to_char(sum(decode(cno,‘c003‘,score))),‘-‘) c003,avg(score) 平均分,sum(score) 总成绩
from sc
group by sno;

结果:

技术分享

 

decode 横竖转换 2