1.sql中的
2.DBMS
3.行列转换
username | course | score |
张三 | python | 90 |
张三 | mysql | 91 |
李四 | python | 95 |
李四 | myqsl | 99 |
1.选根据姓名进行分分组
select username from stu group by username 2.decode函数 case 字段 when 值1 then 结果1 when 值1 then 结果1 ....... else 结果n end 3.代码如下: select username, sum(case course when ‘mysql‘ then score else 0 end) as mysql, sum(case course when ‘python‘ then score else 0 end) as python from stu
group by username;
username | mysql | python |
张三 | 91 | 90 |
李四 | 99 | 95 |
select username,‘mysql‘ course,mysql score from vstu union all select username,‘python‘ course,pythonscore from vstu
数据有转换到以前表
原文:https://www.cnblogs.com/lee88888/p/13168431.html