数据库课后习题参考答案

内容发布更新时间 : 2025/5/17 7:52:09星期一 下面是文章的全部内容请认真阅读。

. . . .

2.查询计算机系的学生的姓名、年龄。

答:select sname,sage from student where sdept = '计算机系'

3. 查询成绩在70~80分之间的学生的学号、课程号和成绩。

答:select sno,cno,grade from sc on where grade between 70 and 80

4. 查询计算机系年龄在18~20之间且性别为“男”的学生的姓名、年龄。 答:select sname,sage from student

where sdept = '计算机系' and sage between 18 and 20 and ssex = '男'

5. 查询“C001”号课程的最高分。

答:select max(grade) from sc where cno = 'C001'

6. 查询计算机系学生的最大年龄和最小年龄。

答:select max(sage) as max_age, min(sage) as min_age from student where sdept = '计算机系'

7. 统计每个系的学生人数。

答:select sdept,count(*) from student group by sdept

8. 统计每门课程的选课人数和考试最高分。

. word资料可编辑 .

. . . .

答:select cno, count(*),max(grade) from sc group by cno

9. 统计每个学生的选课门数和考试总成绩,并按选课门数升序显示结果。 答:select sno,count(*), sum(grade) from sc group by sno

order by count(*) asc

10. 查询总成绩超过200分的学生,要求列出学号和总成绩。 答:select sno,sum(grade) from sc group by sno

having sum(grade) > 200

11. 查询选课门数超过2门的学生的学号、平均成绩和选课门数。 答:select sno, avg(grade), count(*) from sc having count(*) > 2

12. 查询选了“C002”课程的学生的姓名和所在系。

答:select sname,sdept from student s join sc on s.sno = sc.sno where cno = 'C002'

13. 查询成绩80分以上的学生的姓名、课程号和成绩,并按成绩降序排列结果。 答:select sname,cno,grade from student s join sc on s.sno = sc.sno where grade > 80 order by grade desc

14. 查询计算机系男生修了“数据库基础”的学生的姓名、性别和成绩。

.

>>展开全文<<
12@gma联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4 ceshi