数据库实验五数据的查询(4学时)

编程入门 行业动态 更新时间:2024-10-26 05:31:20

数据库实验五数据的查询(4<a href=https://www.elefans.com/category/jswz/34/1755339.html style=学时)"/>

数据库实验五数据的查询(4学时)

这个应该要两个小时的上机实验吧,我记得第一次做这个实验,我没做完,下面是我课后做的除了最后三小题还没写,12.13.14.15我没找到书上的例子不知道对不对,留下参考,等下次问老师,看老师的方法

实验五SQL的数据查询(4学时)

一、实验目的

1. 熟练使用SQL语言select 命令进行数据库数据的各类查询:单表查询、多表连接查询、分组统计查询及嵌套查询等。

2.会使用带有子查询的数据更新命令insert、update、delete。

 

二、实验准备及任务

1.复习教材上SQL语言中select 命令和带有子查询的insert、update、delete

命令。

2.使用教师已经录入相关数据的附录二的“xsglsjk”数据库,完成以下查询,预先写好相应的命令。

(1)查询姓名中第二个字为“勇”的男学生的姓名和班级。

(2)查询成绩为68、78、88和98的选修记录。

(3)查询选修了“4”号课程没有成绩的学生学号。

(4)查询“00311”班所有女生的学号、姓名和出生年份。

(5)查询“李勇敏”同学的班长姓名。

(6)查询“2001102”同学的选课门数。

(7)统计学生表中的班级数。

(8)查询“00311”班每位同学的课程平均分。

(9)查询哪些学生最低分大于70,最高分小于90,输出他们的学号。

(10)计算Student×Cj×Course的结果。

(11)以clno升序、Sage降序列出Student表的学生信息。

(12)列出成绩高于学号为“2000101”、课程号为“3”的成绩的所有选课记录。

(13)查询和“张婷婷”同学在同一班级的学生信息。

(14)查询不及格课程在三门及以上的同学。

(15)*查询选修了目前Course中所有课程的同学。

3. 完成带有子查询的insert、update、delete的任务,预先写好相应的命令。

(16)对每位同学,求平均成绩,并把结果存入新建立的表中。

(17)将班级号为“01312”班级的所有女学生的成绩加5分。

(18)删除“01311”班级的所有学生的成绩记录。

 mycode:

select sname,clno
from student
where sname like '_勇%';select sno
from cj
where grade in ('68', '78', '88', '98');
--或者写成where grade = 68 or grade = 78 or grade = 88 or grade = 98;两者等价select sno
from cj
where cno = 4 and grade is null;select sno, sname, 2018 - sage
from student
where clno = '00311' and ssex = '女';select sname 
from student
where sno = (select monitorfrom class where clno = (select clno from studentwhere sname = '李勇敏'))select count(cno)
from cj
where sno = '2001102'select count(distinct clno)
from student select sno,avg(grade)
from cj
where sno in (select snofrom studentwhere clno = '00311')
group by snoselect sno 
from cj
group by sno
having min(grade)>70 and max(grade)<90;select student.sno,sname,ssex,sage,grade,clno
from student,cj,course
where student.sno = cj.sno;select sno,clno,sage
from student
order by  sage desc,clno asc;select grade
from cj
where grade > (select gradefrom cjwhere sno = '2000101' and cno = 3)select sno,sage,sname
from student
where clno in (select clno from studentwhere sname = '张婷婷')select Sno
from cj
having count((grade)<60)>30select sno
from cj
where cno = *;


更多推荐

数据库实验五数据的查询(4学时)

本文发布于:2024-02-12 00:07:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1684488.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:学时   数据库   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!