列转行--行转列问题(4)
来源:未知 责任编辑:责任编辑 发表时间:2014-03-23 22:32 点击:次
sum(decode(subject,'英语',score,0)) AS "英语",
sum(decode(subject,'生物',score,0)) AS "生物"
FROM StudentScores
GROUP BY UserName;
目前的数据形式:
目标数据形式:
2、实现方式:
select username,'语文' as subject,"语文" as score from ScoresStudent www.2cto.com
union
select username,'数学' as subject,"数学" as score from ScoresStudent
union
select username,'英语' as subject,"英语" as score from ScoresStudent
union
select username,'生物' as subject,"生物" as score from ScoresStudent;
作者 cupid1102
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>