转换行列--sql

转换行列--sql

执行语句

-- CASE表达式
SELECT name,
sum(CASE title WHEN 'linux' THEN score  ELSE 0 END) AS linux,
sum(CASE title WHEN 'javascript' THEN score ELSE 0 END) AS javascript,
sum(CASE title WHEN 'html5' THEN score ELSE 0 END) AS html5,
sum(CASE title WHEN 'javaEE' THEN score ELSE 0 END) AS javaEE,
sum(CASE title WHEN 'C' THEN score ELSE 0 END) AS C,
sum(CASE title WHEN 'java程序设计' THEN score ELSE 0 END) AS java程序设计,
sum(CASE title WHEN 'jquery' THEN score ELSE 0 END) AS jquery
FROM scores 
GROUP BY name;

图例

转换行列--sql

上一篇:myBatis中使用Map获取key, value的方式


下一篇:mysql 自我练习基础 6:常用函数(数学函数、字符串函数、日期函数、分组合并函数、逻辑函数、if、case when...then.... when...then... else...