数据库原理及应用(第2版)--课后习题参考答案(12)

2021-01-28 20:39

答:在查询结果产生后,提取结果的前若干行数据。

四.上机练习

1.查询学生选课表中的全部数据。

答:select * from SC

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. 统计每门课程的选课人数和考试最高分。

答: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'


数据库原理及应用(第2版)--课后习题参考答案(12).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:65岁以上老人健康体检实施方案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: