首页 > 其他 > 详细

例题:从下边一个成绩表做出三个题,题目比较难理解

时间:2015-04-24 15:42:12      阅读:224      评论:0      收藏:0      [点我收藏+]

               

技术分享

     

 

                     

33、查询成绩比该课程平均成绩低的同学的成绩表。

select*from score a where DEGREE <(select avg(degree) from score b where a.cno=b.cno )

 

-查询每门课最高分学生之外的其他学生分数信息

select*from score a where DEGREE not in(select MAX(degree) from score b where a.cno=b.cno)

a.cno=b.cno 这句代码的意思是在同一门课程中 选出最高分,where degree not in 就是把最高分去掉

--剔除选多门课的每门课最高分

select *from score a where DEGREE not in (select MAX(degree)from score b where a.cno=b.cno) and sno not in (select cno from score

 group by cno having COUNT(*)=1)

select cno from score group by cno having count(*)=1   --这句话表示把学生学一门课的课程都显示出来,前面加个not in 剩下的就是选多门课的课程

 

例题:从下边一个成绩表做出三个题,题目比较难理解

原文:http://www.cnblogs.com/275147378abc/p/4453342.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!