如下
关闭
保存
设置表名称
刷新
重复2.建表三次做如下几个表
按照需求填写数据
1.查询其他系中比计算机系中所有学生年龄都大的学生姓名及年龄。
2.查询与95022同学选修课程一样的同学的学号与姓名。
3.查询选课门数唯一的学生的学号。
4.查询没有选修c3课程的学生姓名。
5.查询至少选修两门课程的学生姓名。
6.查询丁同学没选的课程的课程号。
7.查询至少选修课程号为C2和C4的学生学号。
8.查询平均成绩比95022同学平均分高的学生的学号和姓名。
9.查询自己选修课程中成绩比自己平均分高的那些课程的课程号及学号、成绩。
10.查询哪些课程被三个及以上的同学选修,找出这些课程的课程号及课程名。
11.查询没有选课的学生的信息。
12.查询所有学生的选课情况,包括学号,姓名,课程号,成绩。(全体学生的选课情况)
13.找出选课学生超过2人的课程的平均成绩及选课人数。
14.查询每一门课的间接先修课程名称(即先行课的先行课)
15.查询选修了全部课程的学生姓名。
16.查询被全部学生选修的课程的课程号。
17.查询至少选修了学号为95022的同学选修的全部课程的学生学号。
18.查询至少选修了姓名为张三的同学选修的全部课程的学生学号与姓名。
19.查找被计算机系所有学生选修且课程数大于2的学生的姓名、平均成绩和选课门数并按平均成绩降序排列。
20、查询全部学生的学生学号、姓名以及所选课程的课程号、成绩。(包括没选课的学生)
SELECT sname, sage FROM student WHERE sage > ANY (SELECT sage FROM student WHERE sdept= '计算机')
select sno,sname from student where not exists ( select * from sc x where sno='003'and not exists(select * from sc Y where cno=x.cno and sno=student.sno)) And (select count(*)from sc where sno=student.sno)=(select count(*) from Sc where sno='95022')
select sno,sname from student where sno in(select sno from sc group by sno having count(*)=1)
SELECT sname FROM student WHERE NOT EXISTS (SELECT * FROM sc WHERE sno=student.sno AND cno= 'c3')
select sno,sname from student where sno in(select sno from sc group by sno having count(*)>=2)
select cno,cname from course where cno not in(select cno from sc where sno in(select sno from student where sname='丁同学'))
select sca.sno from sc as sca join sc as scb on sca.sno=scb.sno where sca.cno='c2' and scb.cno='c4';
select sname,sno from student where sno in(select sno from sc group by sno having AVG(grade)>(select AVG(grade) from sc where sno='95022'))
SELECT sno,cno,grade FROM sc x WHERE grade > ( SELECT AVG(grade) FROM sc y WHERE x.sno = y.sno )
select cno,cname from course where cno in(select cno from sc group by cno having count(*)>=3)
SELECT sname FROM student WHERE NOT EXISTS ( SELECT * FROM course WHERE EXISTS (SELECT * FROM sc WHERE sno=student.sno AND cno=course.cno))
SELECT student.sno,sname,course.cno,cname,grade FROM student,course,sc WHERE student.sno=sc.sno and sc.cno=course.cno
select cno,AVG(grade) ,COUNT(cno) from sc group by cno having count(cno)>2
select x.cno,y.cname from course x,course y where x.cno=y.cno
SELECT sname FROM student WHERE NOT EXISTS ( SELECT*FROM course WHERE NOT EXISTS ( SELECT*FROM sc WHERE student.sno = sc.sno AND sc.cno = course.cno) )
SELECT cname FROM course WHERE NOT EXISTS ( SELECT*FROM student WHERE NOT EXISTS ( SELECT*FROM sc WHERE course.cno = sc.cno AND sc.sno = student.sno) )
select distinct sno from student x where not exists ( select * from sc y where y.sno='95022' and not exists ( select * from sc Z where z.cno=y.cno and z.sno=x.sno ) )
select sno,sname from student x where not exists(select*from student y , sc where sname='张三' and y.sno=sc.sno and not exists( select *from sc where cno=sc.cno and sno=x.sno))
select sname,AVG(grade) 平均成绩,COUNT(course.cno) 选课门数 from student,course,sc where student. sno= course.cno AND Sdept='计算机' GROUP BY student .Sno,Sname HAVING COUNT(*)>= 2 ORDER BY SUM(grade) DESC
SELECT student.sno,sname, cname,grade FROM student LEFT join sc on student.sno=sc.sno LEFT join course on sc.cno=course.cno