【请教】怎样用SQL处理这张表
用上面那张表的数据生成下面这张表,SQL该怎么写。多谢! select name as 姓名,max(case when subject='语文' then result else '' end) as `语文`, max(case when subject='数学' then result else '' end) as `数学`, max(case when subject='英语' then result else '' end) as `英语` from stu GROUP BY name
Mysql下的行转列,mssql或oracle的自己找吧 select distinct 学生,
(select distinct 成绩 from student where 科目='语文' and 学生 like a.学生) as 语文,
(select distinct 成绩 from student where 科目='数学' and 学生 like a.学生) as 数学,
(select distinct 成绩 from student where 科目='英语' and 学生 like a.学生) as 英语
from student a
页:
[1]