一张成绩表,学生编号,课程,成绩课程有五门:英语,我想查询后-查字典问答网
分类选择

来自刘志学的问题

  一张成绩表,学生编号,课程,成绩课程有五门:英语,我想查询后这样展示.张三4045454545请教SQL如何写selects.stuname,c1.totalscore,c2.totalscore,c3.totalscore,c4.totalscore,c5.totalscorefromstudentsfulljoin((((

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

  我想查询后这样展示.

  张三4045454545

  请教SQL如何写

  select

  s.stuname,c1.totalscore,c2.totalscore,c3.totalscore,

  c4.totalscore,c5.totalscore

  from

  studentsfulljoin

  ((((

  chengjic1leftjoinchengjic2

  onc1.topless=0andc2.topless=1andc1.stu id=c2.stuid)

  leftjoinchengjic3

  onc3.topless=2andc1.stu id=c3.stuid)

  leftjoinchengjic4

  onc4.topless=3andc1.stu id=c4.stuid)

  leftjoinchengjic5

  onc5.topless=4andc1.stu id=c5.stuid)

  ons.stu id=c1.stuidwheres.stu id=102

  这是我的sql语句但是总是有错误.

  没有分数时,仍能查询出值.

1回答
2020-11-05 23:11
我要回答
请先登录
陈晓锋

  selects.name,

  sum(casetoplesswhen0thentotalscoreelse0end)数学,

  sum(casetoplesswhen1thentotalscoreelse0end)语文,

  sum(casetoplesswhen2thentotalscoreelse0end)英语,

  sum(casetoplesswhen3thentotalscoreelse0end)政治,

  sum(casetoplesswhen4thentotalscoreelse0end)历史

  fromstudentsleftjoinchengjicons.stu id=c.stuid

  groupbys.name,s.stuid

2020-11-05 23:15:40

最新问答

推荐文章

猜你喜欢

附近的人在看

推荐阅读

拓展阅读

  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  •