一张成绩表,学生编号,课程,成绩 课程有五门:英语,

一张成绩表,学生编号,课程,成绩 课程有五门:英语,
我想查询后这样展示.
张三 40 45 45 45 45
请教SQL如何写
select
s.stuname,c1.totalscore,c2.totalscore,c3.totalscore,
c4.totalscore,c5.totalscore
from
student s full join
((((
chengji c1 left join chengji c2
on c1.topless=0 and c2.topless=1 and c1.stuid=c2.stuid)
left join chengji c3
on c3.topless=2 and c1.stuid=c3.stuid)
left join chengji c4
on c4.topless=3 and c1.stuid=c4.stuid)
left join chengji c5
on c5.topless=4 and c1.stuid=c5.stuid)
on s.stuid=c1.stuid where s.stuid=102
这是我的sql 语句 但是总是有错误 .
没有分数时,仍能查询出值.
落叶寒衣 1年前 已收到1个回答 举报

口香糖和可乐 幼苗

共回答了18个问题采纳率:88.9% 举报

select s.name,sum(case topless when 0 then totalscore else 0 end)数学,sum(case topless when 1 then totalscore else 0 end)语文,sum(case topless when 2 then totalscore else 0 end)英语,sum(case topless w...

1年前

3
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 17 q. 0.092 s. - webmaster@yulucn.com