例子:
SELECT name,SUM(CASE when `subject`='语文' then fenshu end) as '语文',SUM(CASE when `subject`='数学' then fenshu end) as '数学' ,SUM(CASE when `subject`='英语' then fenshu end) as '英语' from chengji GROUP BY name
本文共 271 字,大约阅读时间需要 1 分钟。
例子:
SELECT name,SUM(CASE when `subject`='语文' then fenshu end) as '语文',SUM(CASE when `subject`='数学' then fenshu end) as '数学' ,SUM(CASE when `subject`='英语' then fenshu end) as '英语' from chengji GROUP BY name
转载于:https://www.cnblogs.com/penty/archive/2013/03/22/2975347.html