云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > sqlServer2005习题与答案

sqlServer2005习题与答案

  • 62 次阅读
  • 3 次下载
  • 2025/12/11 1:45:56

sqlServer2005习题与答案

从学生表Student(Sno,Sname,Ssex,Sage,Sdept)中查询出全体学生的学号与姓名 1. 查询全体学生的详细记录 2. 显示前 5条纪录 3. 显示前 50%条纪录

4. 查询所有年龄在17岁以下的学生姓名及其年龄。 5. 某些学生选修课程后没有参加考试,所以有选课记录,但没有考试成绩。查询缺少成绩的学生的学号和相应的课程号。(成绩为null)

6. 查所有有成绩的学生学号和课程号 7. 查询学生的所有信息,按学号的降序排列 1.select * from student 2.select top 5 * from student

3.select top 50 percent * from student 4.select sname,sage from student where sage<17

5.select sno,cno from sc where score is NULL

6.select sno,cno from sc where score is not NULL

7.select * from student order by sno desc 8 查询选修了课程的学生学号

9. 查全体学生的姓名及其出生年份,显示两列:姓名、出生年份

10. 查询年龄在15~17岁(包括15岁和17岁)之间的学生的姓名、年龄。

11. 查询年龄不在15~17岁之间的学生姓名、系别和年龄。

12. 查询年龄不在15~17岁之间的男生姓名、系别和年龄。

13. 将上题查询的结果插入一个新表中。 8.select distinct sno from sc

9.select sname,2010-sage as 出生年份 from student

10.select sname,sage from student where sage between 15 and 17

11.select sname,sdept,sage from student where sage is not between 15 and 17

12.select sname,sdept,sage from student where ssex='男' and sage is not between 15 and 17 13.select sname,sdept,sage into newtable from student where ssex='男' and sage is not between 15

and 17

1. 查询学生总人数。

2. 查询选修了课程的学生人数。 3. 计算1001号课程的学生平均成绩。 4. 查询选修1号课程的学生最高分数。

5. 求各个课程号及相应的选课人数。(group by) 6. 查询选修了1门以上课程的学生学号。(having) 7. 请说明union的作用。

1.select count(*) from student

2.select count(distinct sno) as 人数 from sc

3.select avg(score) as 平均成绩 from sc where cno =1001

4.select max(score) as 最高分数 from sc where cno =1

5.select cno,count(*) as 选课人数 from sc group by cno

6.select cno, count(*) as 选课人数 from sc group by cno having count(*)>1 1. 查询学生总人数。

2. 查询选修了课程的学生人数。 3. 计算1001号课程的学生平均成绩。

4. 查询选修1001号课程的学生最高分数。 5. 求各个课程号及相应的选课人数。(group by) 6. 查询选修了1门以上课程的学生学号。(having) 7. 请说明union的作用。

1.select count(*) as 总人数 from student >2.select count(distinct sno) as 总人数 from sc >3.select avg(score) as 平均成绩from sc where cno=1001 >4.select max(score) from sc where cno=1001

>5.select cno,count(*)as 人数,max(score ) from sc group by cno

>6.select sno from sc group by sno having count(cno)>1

>7.在列数和列的顺序相同且数据类型相同的前提下,将多个select语句返回的结果组合到同一个结果当中。 >请举例说明With cube和With rollup的作用。 select cno,cname,count(cno)as 人数 from course group by cno,cname with cube说明每一个分组统计的总数 select cno,cname,count(cno)as 人数from course group by cno,cname with rollup说明每一个小分组的统计总数 >3. 使用compute 汇总所有学生的成绩平均分。

select sno,cno,score from sc compute avg(score)

搜索更多关于: sqlServer2005习题与答案 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

sqlServer2005习题与答案 从学生表Student(Sno,Sname,Ssex,Sage,Sdept)中查询出全体学生的学号与姓名 1. 查询全体学生的详细记录 2. 显示前 5条纪录 3. 显示前 50%条纪录 4. 查询所有年龄在17岁以下的学生姓名及其年龄。 5. 某些学生选修课程后没有参加考试,所以有选课记录,但没有考试成绩。查询缺少成绩的学生的学号和相应的课程号。(成绩为null) 6. 查所有有成绩的学生学号和课程号 7. 查询学生的所有信息,按学号的降序排列 1.select * from student 2.select top 5 * from student

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com