我明白下列两语句之不同,但不能理解.初学SQL2005 请教!
select 课程,
sum(case when 姓名='李四' then 成绩 end)as '李四',
sum(case when 姓名='张三' then 成绩 end)as '张三'
from table_2
group by 课程
select 姓名,
sum(case when 课程='语文' then 成绩 end)as '语文',
sum(case when 课程='数学' then 成绩 end)as '数学',
sum(case when 课程='英语' then 成绩 end)as '英语'
from table_2
group by 姓名
table_2是表名 姓名,课程,成绩是列名。)其他是对应列的数据
希望可以帮我找到更多的知识。
繁星点点滴滴
catspeake
相关分类