码迷,mamicode.com
首页 > 其他好文 > 详细

select 练习4

时间:2016-12-19 14:07:28      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:min   com   分数   select   成绩   alt   height   不同   order   

21、查询score中选学多门课程的同学中分数不是所有成绩中最高分成绩的记录。

select * from score  where cno in(select cno from score group by cno having count(1)>1) and degree<>(select max(degree) from score);

技术分享

 

 

24、查询选修某课程的同学人数多于5人的教师姓名。

select t.tname from teacher t join course c on t.tno = c.tno where c.cno in (select cno from score group by cno having count(1)>5);

技术分享

 

 

26、  查询存在有85分以上成绩的课程Cno.

select cno from score where degree in (select degree from score group by degree having degree>85);

技术分享

 

27、查询出“计算机系“教师所教课程的成绩表。

select s.* from score s join course c on s.cno = c.cno join teacher t on t.tno = c.tno where t.depart = ‘计算机系‘;

技术分享

 

28、查询“计算机系”与“电子工程系“不同职称的教师的TnameProf

select t.tname,t.prof from teacher t where t.prof in(select t.prof from teacher t group by t.prof having count(1)=1)

技术分享

 

 

29、查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的CnoSnoDegree,并按Degree从高到低次序排序。

select cno,sno,degree from score where cno=‘3-105‘
and degree>=(select min(degree) from score where cno=‘3-245‘) order by degree desc;

技术分享

 

 

30、查询选修编号为“3-105”且成绩高于选修编号为“3-245”课程的同学的CnoSnoDegree.

select cno,sno,degree from score where cno=‘3-105‘ and degree> (select max(degree) from score where cno=‘3-245‘);

技术分享

 

31、 查询所有教师和同学的namesexbirthday.

select s.sname,s.ssex,s.sbirthday from student s union select t.tname,t.tsex,t.tbirthday from teacher t;

 

技术分享

 

32、查询所有“女”教师和“女”同学的namesexbirthday.

select s.sname,s.ssex,s.sbirthday from student s where s.ssex=‘女‘ union select t.tname,t.tsex,t.tbirthday from teacher t where t.tsex=‘女‘;

技术分享

 

select 练习4

标签:min   com   分数   select   成绩   alt   height   不同   order   

原文地址:http://www.cnblogs.com/dnf1612/p/6192892.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!