查询各科成绩最高分、最低分、平均分以如下形式显示:课程ID、课程NAME、最高分、最低分、及格率、中等率、优良率、优秀率、不及格率 及格为>=60 中等为70-80 优良为80-90 优秀为>=90

时间:2025-03-22 07:13:34

select .c_no,.c_name,.s_score,
round(avg(.s_score),2)avg_score,
min(.s_score)min_score,
max(.s_score)max_score,

round(100*(sum(case when .s_score>=60 and .s_score<70 then 1 else 0 end)/sum(case when .s_score then 1 else 0 end)),2) as 及格率,
round(100*(sum(case when .s_score>=70 and .s_score<80 then 1 else 0 end)/sum(case when .s_score then 1 else 0 end)),2) as 中等率,
round(100*(sum(case when .s_score>=80 and .s_score<90 then 1 else 0 end)/sum(case when .s_score then 1 else 0 end)),2) as 优良率,
round(100*(sum(case when .s_score>=90 then 1 else 0 end)/sum(case when .s_score then 1 else 0 end)),2) as 优秀率,
round(100*(sum(case when .s_score<60 then 1 else 0 end)/sum(case when .s_score then 1 else 0 end)),2) as 不及格率

from ,
where .c_no=.c_no
group by .c_no