#20、查询score中选学多门课程的同学中分数为非最高分成绩的记录。 select * from Score a where Sno in (select Sno from Score group by Sno having count(*)>1 ) and Degree not in (select max(Degree) from Score b where b.Cno = a.Cno); #21、查询成绩高于学号为“109”、课程号为“3-105”的成绩的所有记录。 select * from score where cno = '3-105' and degree>(select degree from score where sno = '109'and cno='3-105'); #22、查询和学号为108的同学同年出生的所有学生的Sno、Sname和Sbirthday列 select sno,sname,sbirthday from student where year(sbirthday)=(select year(sbirthday) from student where sno='107'); #23、查询“张旭“教师任课的学生成绩(姓名)。 select sname,degree from teacher join course on teacher.tno = course.tno join score on course.cno = score.cno join student on student.sno = score.sno where tname = '张旭'; select sname,degree from score join course on score.cno = course.cno join teacher on teacher.tno = course.tno join student on score.sno = student.sno where tname = '张旭'; #24、查询考计算机导论的学生成绩 select sname,degree from course join score on course.cno=score.cno join student on student.sno=score.sno where course.cname='计算机导论'; 24.1、查询李诚老师教的课程名称 select cname from course join teacher on course.tno=teacher.tno where tname='李诚'; 24.2、教高等数学的老师是哪个系的 select depart from teacher join course on teacher.tno= course.tno where cname='高等数学'; 24、查询选修某课程的同学人数多于5人的教师姓名。 25、查询95033班和95031班全体学生的记录。 select * from student where clsaa='95033' or clsaa='95031'; 26、 查询存在有85分以上成绩的课程Cno. select cno from score where degree>'85'; 27、查询出“计算机系“教师所教课程的成绩表。 select degree from score join course on score.cno=course.cno join teacher on teacher.tno=course.tno where depart='计算机系'; 29、查询选修编号为“3-105“课程且成绩至少高于选修编号为“3-245”的同学的Cno、Sno和Degree,并按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”课程的同学的Cno、Sno和Degree. select cno,sno,degree from score where cno='3-105' and degree>(select max(degree) from score where cno='3-245'); 31、 查询所有教师和同学的name、sex和birthday. select tname,tsex,tbirthday from teacher union select sname,ssex,sbirthday from student; 32、查询所有“女”教师和“女”同学的name、sex和birthday. select tname,tsex,tbirthday from teacher where tsex='女' union select sname,ssex,sbirthday from student where ssex='女'; 33、 查询成绩3-105课程平均成绩低的同学的成绩表。 select * from score where degree<(select avg(degree) from score where cno = '3-105'); 34、 查询所有任课教师的Tname和Depart. select tname,depart from teacher; 35、查询所有未讲课的教师的Tname和Depart. select tname,depart from teacher where prof !='助教'; 35、查询所有未讲课的教师的Tname和Depart. select tname,depart from teacher where prof ='助教'; 36、查询至少有2名男生的班号。 select clsaa from student group by clsaa,ssex having ssex='男' and count(ssex)>=2; 37、查询Student表中不姓“王”的同学记录。 select * from student where sname not like '王_'; 38、查询Student表中每个学生的姓名和年龄。 select sname,year(now())-year(sbirthday) from student; 39、查询Student表中最大和最小的Sbirthday日期值。 select min(sbirthday),max(sbirthday) from student; 40、以班号和年龄从大到小的顺序查询Student表中的全部记录。 select clsaa,year(now())-year(sbirthday) from student group by clsaa desc,sbirthday; 41、查询“男”教师及其所上的课程。 select teacher.*,cname from teacher join course on teacher.tno=course.tno where tsex='男'; 42、查询最高分同学的Sno、Cno和Degree列。 select sno,cno,degree from score where degree in (select max(degree) from score); 43、查询和“李军”同性别的所有同学的Sname. select sname from student where ssex in (select ssex from student where sname = '李军'); 44、查询和“李军”同性别并同班的同学Sname. select sname from student where ssex in (select ssex from student where sname = '李军') and clsaa in (select clsaa from student where sname = '李军'); 45、查询所有选修“计算机导论”课程的“男”同学的成绩表。 select degree from score where cno in (select cno from course where cname='计算机导论') and sno in (select sno from student where ssex='男'); 查表练习20-45
转载于:https://www.cnblogs.com/cp123/p/8939955.html
相关资源:DirectX修复工具V4.0增强版