1.oracle语句
-- 按各科平均成绩从低到高和及格率的百分数从高到低排序
select sc.cid as 课程id,avg(sc.score) as 平均成绩,
100*sum(case when sc.score>=60 then 1 else 0 end)/count(1)||'%' as 及格率
from sc
group by sc.cid
order by avg(sc.score),
sum(case when sc.score>=60 then 1 else 0 end)/count(1) desc;
2.效果图