求助:一道练习题sql语句怎么写?
发布网友
发布时间:2022-04-27 07:46
我来回答
共2个回答
热心网友
时间:2022-04-07 17:43
select a.name,a.score 语文,b.score 化学,c.score 英语 from
(select name,score from student where course='语文' ) a
left join
(select name,score from student where course='化学' ) b
on a.name=b.name
left join
(select name,score from student where course='英语' ) c
on a.name = c.name
热心网友
时间:2022-04-07 19:01
select name,case when course='语文' then score end as '语文',
case when course='化学' then score end as '化学',
case when course='英语' then score end as '英语'
from student;
这是列转行,行转列的话用UNION ALL追问你写的这条sql语句执行提示:未找到要求的FROM关键字
追答逗号估计是中文的,要换成英文的