大学计算机—计算思维导论C 习题 求解

题目:有如下关系数据库:
学生关系:Student(S#, Sname, Sage, Sclass),其属性依次为“学号,姓名,年龄,班级”;
课程关系:Course(C#, Cname, Chours, Credit, Cteacher),其属性依次为“课程号,课程名,
学时,学分,授课教师”;
学生选课关系:SC(S#, C#, Score),其属性依次为“学号,课程号,成绩”
请针对以上关系,使用 SQL 语句实现下列查询。
(1)所有年龄小于 18 岁并且大于 15 岁的学生的学号、姓名和年龄,并按学号由大到小的
顺序排列;
(2)所有姓李的学生学号及姓名;
(3)选修了“操作系统”课程的学生的学号、姓名、成绩;
(4)统计每一门课程的最高分、最低分和平均成绩

(1)
select `S#`,Sname,Sage
from Student
where Sage<18 and Sage >15
order by `S#` DESC;
(2)
select `S#`,Sname
from Student
where Sname like '李%';
(3)
select Student.`S#`,Sname,SC.SCORE
from Course,Student,Sc
where Course.Cname='操作系统'and Course.`C#`=SC.`C#` and Student.`S#`=SC.`S#`;
(4)
Select Course.Cname, Max(Score),Min(Score),AVG(Score)
from Course,Sc
where Course.`C#` =SC.`C#`
group by Course.`C#`;

img

img

img

img


img

(1)
select 'S#',Sname,Sage from Student where Sage < 18 and Sage > 15 order by 'S#' desc;
(2)
select 'S#',Sname from Student where Sname like "李%";
(3)
select Student.`S#` ,Sname, Score from Student,Course,SC where Cname ='操作系统' and Student.`S#` and SC.`S#` and Course.`C#` and SC.`C#`4Select Course.Cname, Max(Score),Min(Score),AVG(Score) from Course,Sc where Course.`C#` =SC.`C#` group by Course.`C#`;