《数据库》实验报告2
2、列出同时选修了'数学’和'数据库’的学生学号、姓名;
select student.sno,sname
from student,sc
where cno in (select cno from course
where cname='数学')and sc.sno=student.sno
intersect
select student.sno,sname
from student,sc
where cno in (select cno from course
where cname='数据库')and sc.sno=student.sno
3、查询缺少成绩的所有学生的详细情况;
select * from student,sc where Grade is null and student.sno=sc.sno
查询缺少成绩的所有学生的学号姓名;
select student.sno sname from student,sc where Grade is null and student.sno=sc.sno
4、查询与'李勇’ 年龄相同的所有学生的信息;
select * from student
where sage =(select sage from student where sname='李勇') and sname <> '李勇’
查询与'杨磊’年龄不相同的所有学生的信息;
select * from student
where sage <>(select sage from student where sname='杨磊')
7、按照“学号,姓名,所在院系,不及格课程门数”的顺序列出学生有课程不及格的情况。
select student.sno,sname,sdept,count(grade) 不及格门数 from student,sc
where student.sno=sc.sno and grade<60 group by student.sno,sname,sdept
9、查询只被一名学生选修的课程的课程号;
select cno from sc group by Cno having COUNT(sno)=1