有一个学生课程数据库:包括学生表S、课程表C和成绩表SC,它们的结构如下:
学生表(S):

写出下面的SQL语句:
1)查询所有学过数据库的学生的姓名,并按姓名由大到校排序。
注:由于重修、补考,一个学生可能有多个考试成绩,查询结果只输出一个。
2)查询所修学分超过80的学生,输出学生学好和所修学分。
3)给SC表增加代课老师字段Teacher,数据类型为字符串,长度20,非空。
4)创建每个学生学习总分的视图,字段有学号,总分。视图名为SCsum。
5)删除SC表中,学号在学生表中不存在的记录。
解法一:
1)select Sname from S where Sno in (select distinct Sno from Cno where Cno =(select Cno from C where Cname='数据库')) order by Sname desc;
2)select S.Sno,C.Ccredit from S,C,(select Sno,Cno from SC where Grade>80)temp where S.Sno=temp.Sno and C.Cno=temp.Cno;
3)alter table SC add Teacher varchar(20) not null;
4)create view SCsum as (select Sno,sum(grade) sum from SC group by Sno);
5) delete from SC where Sno in (select Sno from SC minus select Sno from S);
解法二:
1)select distinct t3.Sname from SC t1 inner join C t2 on t1.Cno = t2.Cnoinner join S t3 on t1.Sno = t3.Sno where t2.Cname='数据库' order by t3.Sname;
2)select t1.Sno, sum(t2.Ccredit) from SC t1 inner join C t2 on t1.Cno = t2.Cno where t1.Grade > 59 group by t1.Sno having sum(t2.Ccredit) > 80;
3)alter table SC add Teacher char(20) not null;
4)create view SCSum as(select t1.Sno, sum(Grade)from SC t1 group by t1.Sno);
5)delete from SC where SC.Sno not in(select t2.Sno from S t2);
学生表(S):

写出下面的SQL语句:
1)查询所有学过数据库的学生的姓名,并按姓名由大到校排序。
注:由于重修、补考,一个学生可能有多个考试成绩,查询结果只输出一个。
2)查询所修学分超过80的学生,输出学生学好和所修学分。
3)给SC表增加代课老师字段Teacher,数据类型为字符串,长度20,非空。
4)创建每个学生学习总分的视图,字段有学号,总分。视图名为SCsum。
5)删除SC表中,学号在学生表中不存在的记录。
解法一:
1)select Sname from S where Sno in (select distinct Sno from Cno where Cno =(select Cno from C where Cname='数据库')) order by Sname desc;
2)select S.Sno,C.Ccredit from S,C,(select Sno,Cno from SC where Grade>80)temp where S.Sno=temp.Sno and C.Cno=temp.Cno;
3)alter table SC add Teacher varchar(20) not null;
4)create view SCsum as (select Sno,sum(grade) sum from SC group by Sno);
5) delete from SC where Sno in (select Sno from SC minus select Sno from S);
解法二:
1)select distinct t3.Sname from SC t1 inner join C t2 on t1.Cno = t2.Cnoinner join S t3 on t1.Sno = t3.Sno where t2.Cname='数据库' order by t3.Sname;
2)select t1.Sno, sum(t2.Ccredit) from SC t1 inner join C t2 on t1.Cno = t2.Cno where t1.Grade > 59 group by t1.Sno having sum(t2.Ccredit) > 80;
3)alter table SC add Teacher char(20) not null;
4)create view SCSum as(select t1.Sno, sum(Grade)from SC t1 group by t1.Sno);
5)delete from SC where SC.Sno not in(select t2.Sno from S t2);