转换行列--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;

图例

posted @ 2021-11-30 13:48  阿向向  阅读(52)  评论(0编辑  收藏  举报