班级考试人数大于10、班级最低分在50分以上、计算机学院、班级平均分从高到低前10名

/*表scores有四个字段,学生stu、班级class、学院institute、分数score。 
要求返回:班级考试人数大于10、班级最低分在50分以上、计算机学院、班级平均分从高到低前10名。
可以用任意数据库写SQL 返回字段为班级,平均分。
*/

--不准嵌套语句。
select top 10 class,平均分=avg(score) from tb 
where  institute='计算机学院' 
group by class   
having count(1)>=10 and min(score)>=50 
order by avg(score) desc



posted @ 2010-01-03 11:05  曾祥展  阅读(1275)  评论(0编辑  收藏  举报