第14题完整答案,楼主没有写出课程name:
select course.CId as '课程id',
course.Cname as '课程name',
max(sc.score) as '最高分',
min(sc.score) as '最低分',
avg(sc.score) as '平均分',
count(sc.SId) as '选修人数',
sum(case when sc.score >=60 then 1 else 0 end)/count(sc.SId) as '及格率',
sum(case when sc.score >70 and sc.score<=80 then 1 else 0 end)/count(sc.SId) as '中等率',
sum(case when sc.score >80 and sc.score<=90 then 1 else 0 end)/count(sc.SId) as '优良率',
sum(case when sc.score >=90 then 1 else 0 end)/count(sc.SId) as '优秀率'
from course left join sc
on course.CId = sc.CId group by course.CId order by count(sc.SId) desc,course.CId asc;
50道SQL练习题及答案与详细分析网上流传较广的50道SQL训练,奋斗了不知道多久终于写完了。前18道题的难度依次递增,从19题开始的后半部分算是循环练习和额外function的附加练习,难度恢复到普通状态。...