数据库实验二Word格式文档下载.docx

上传人:b****1 文档编号:15369030 上传时间:2022-10-29 格式:DOCX 页数:14 大小:198.16KB
下载 相关 举报
数据库实验二Word格式文档下载.docx_第1页
第1页 / 共14页
数据库实验二Word格式文档下载.docx_第2页
第2页 / 共14页
数据库实验二Word格式文档下载.docx_第3页
第3页 / 共14页
数据库实验二Word格式文档下载.docx_第4页
第4页 / 共14页
数据库实验二Word格式文档下载.docx_第5页
第5页 / 共14页
点击查看更多>>
下载资源
资源描述

数据库实验二Word格式文档下载.docx

《数据库实验二Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《数据库实验二Word格式文档下载.docx(14页珍藏版)》请在冰豆网上搜索。

数据库实验二Word格式文档下载.docx

4.在SQL 

Server查询分析器中使用IN、比较符、ANY或ALL和EXISTS操作符进行嵌套查询操作。

二、实验内容

(1)查询数学系学生的学号和姓名。

(2)求选修了课程的学生学号。

(3)查询选修001号课程的学生学号和成绩,并要求对查询结果按成绩降序排列,如果成绩相同则按学号升序排列。

(4)求选修课程001且成绩在80—90分之间的学生学号和成绩,并将成绩乘以系数0.8输出。

(5)求数学系或计算机系姓张的学生的信息。

(6)查看选修了课程、但没有成绩学生的学号、姓名、课程号和所在系部。

(7)查询学生的学号、姓名、课程名和成绩。

(8)分别实现学生和系的交叉连接、内连接、外连接。

(9)求选修了高等数学的学生学号和姓名。

(10)求001课程的成绩高于张力的学生学号和成绩。

(11)求其他系中年龄小于计算机系年龄最大者的学生。

(12)求其他系中比计算机系学生年龄都小的学生。

(13)求选修了001课程的学生姓名。

(14)求没有选修001课程的学生姓名。

(15)查询选修了全部课程的学生的姓名。

(16)求选修了学号为“200210102”的学生所选修的全部课程的学生学号和姓名。

selectstudent.sname,student.sno

fromstudent,depart

wherestudent.sdept=depart.sdepanddepart.dname='

数学系'

selectdistinct(student.sno)

fromstudent,sc

wherestudent.sno=sc.sno

selectstudent.sno,student.sname,sc.grade

wherestudent.sno=sc.snoandcno='

1'

orderbysc.gradedesc,student.snoasc

selectstudent.sno,(sc.grade)*0.8

wherestudent.sno=sc.snoando='

andsc.grade>

=80andsc.grade<

=90

select*

wherestudent.sdept=depart.sdep

anddepart.dnamein('

'

计算机系'

andstudent.snamelike'

张%'

wherestudent.sno=sc.snoandsc.gradeisnull

selectstudent.sno,student.sname,o,sc.grade

fromstudent,sc,course

wherestudent.sno=sc.snoando=o

右外连接

selectstudent.sno,student.sname,student.sdept

fromstudentleftjoindeparton(student.sdept=depart.sdep)

交叉连接

select*fromstudentcrossjoindepart

内连接

9)求选修了高等数学的学生学号和姓名。

selectstudent.sno,student.sname

wherestudent.sno=sc.snoando=oandame='

数学'

andsc.grade>

(selectsc.grade

wherestudent.sno=sc.snoando=oandstudent.sname='

张立'

andame='

selectstudent.sname

wherestudent.sage<

(selectmax(student.sage)

anddepart.dname<

>

'

andstudent.sdept=depart.sdep

all(selectstudent.sage

fromstudent

wherenotexists(

fromsc

 

wherenotexists(select*

fromcourse

wherestudent.sno=sc.snoando=o));

(16)求选修了学号为“95005”的学生所选修的全部课程的学生学号和姓名。

selectdistinctsno

fromscscx

select*

fromscscy

wherescy.sno='

95021'

andnotexists(select*

fromscscz

wherescz.sno=scx.snoando=o))

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 考试认证 > 交规考试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1