查询每个学生高于他自己选修平均分的那门课程的成绩,输出学号,课程号,课程成绩,他所有课程的平均分,并按学号升序排列。
select sc.sno,cno,grade, avg_grade from sc,
(select sno,round(avg(grade)) from sc group by sno )as avg_sc(avg_sno,avg_grade)
where sc.sno=avg_sc.avg_sno and grade>avg_grade order by sno
查询每个学生高于他自己选修平均分的那门课程的成绩,输出学号,课程号,课程成绩,他所有课程的平均分,并按学号升序排列。
select sc.sno,cno,grade, avg_grade from sc,
(select sno,round(avg(grade)) from sc group by sno )as avg_sc(avg_sno,avg_grade)
where sc.sno=avg_sc.avg_sno and grade>avg_grade order by sno