请问有这样的两个表:课程表subject-inf(课程号,课程类别,学期,课程名称,学分)学生成绩表studentscore-inf(学号,课程名称(课程名称下面放的成绩),对这样的两个表如何进行查询并按课程不及格人数由高到低进行排序,显示课程名和不及格人数,并且具体参加的排序人数先得在学生基础信息表确认,studentsbasic_inf(学号,姓名,宿舍号,性别,年龄)
跟上个问题基本一样,只是要关联一下课程表得到课程名称。
select courseName 课程名,count(1) 不及格科目数量 from(
select 'C语言程序设计' as courseName from studentsscore_inf s inner join studentsbasic_inf b on s.学号=b.学号 where s.C语言程序设计<60
union all
select '高等数学A1' as courseName from studentsscore_inf s inner join studentsbasic_inf b on s.学号=b.学号 where s.高等数学A1<60
union all
select '大学英语A1' as courseName from studentsscore_inf s inner join studentsbasic_inf b on s.学号=b.学号 where s.大学英语A1<60
union all
select '大学体育A1' as courseName from studentsscore_inf s inner join studentsbasic_inf b on s.学号=b.学号 where s.大学体育A1<60
)t group by t.courseName
order by count(t.courseName) desc
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!