4、查询选修了C02课程的学生的学号、姓名。
答:select a.Sno, a.Name from Student a , Grade b where a. Sno = b. Sno and b. Cno ='C02'
5、查询管理学院学生的学号、姓名。
答:select a.Sno, a.Name from Student a , Dept b where a. Dno = b. Dno and b. Dname ='管理学院'
6、查询每个学生的平均成绩并按学号分别输出。
答:SELECT Grade.sno,Student.name,AVG(score) as AvgScore FROM Grade,Student where Grade.sno=Student.sno GROUP BY Grade.sno,Student.Name
7、在成绩表中插入一个记录,其中学号为02,课程号为C01,成绩为87。 答:Insert into Grade(Sno,Cno,Score) values('02','C01',87)
8、将课程表中C03课程的学时改为64,学分改为4。
答:update Course set Time ='64', Ccredit = 4 where Cno ='C03'
9、建立由学号、姓名、年龄构成的学生视图Stud。 答:
CREATE VIEW dbo.[ Stud] AS
SELECT Sno, Name, Sage FROM dbo.student
10、将学时小于等于16的课程从课程表中删除。
答:delete from Course where Cno in (select Cno from Course where Time < 16 and Cno not in (select Cno from Grade))
- 6 -