欢迎来到课桌文档! | 帮助中心 课桌文档-建筑工程资料库
课桌文档
全部分类
  • 党建之窗>
  • 感悟体会>
  • 百家争鸣>
  • 教育整顿>
  • 文笔提升>
  • 热门分类>
  • 计划总结>
  • 致辞演讲>
  • 在线阅读>
  • ImageVerifierCode 换一换
    首页 课桌文档 > 资源分类 > DOC文档下载  

    数据的库1数据的查询.doc

    • 资源ID:26279       资源大小:309KB        全文页数:14页
    • 资源格式: DOC        下载积分:10金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要10金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    数据的库1数据的查询.doc

    实验一 数据库查询课程名称:数据库原理实验实验类型:验证型实验名称数据库查询学时4学时实验目的:使学生掌握SQL Server Query Analyzer的使用方法,加深对SQL和T-SQL语言的查询语句的理解。熟练掌握表的根本查询,连接查询和嵌套查询,以与掌握数据排序和数据分组的操作方法。实验原理:SELECT ALL|DISTINCT <目标列表达式>,<目标列表达式>FROM <表名或视图名>,<表名或视图名>WHERE <条件表达式> GROUP BY <列名1> HAVING <条件表达式> order by <列名2> ASC|DESC;实验方法:将查询需求用T-SQL语言表示;在SQL Server Query Analyzer的输入区中输入T-SQL查询语句;设置 Query Analyzer的结果区为Standard Execute标准执行或Execute to Grid网格执行方式;发布执行命令,并在结果区中查看查询结果;如果结果不正确,要进展修改,直到正确为止。实验内容:1. 分别用带DISTINCT和不带DISTINCT关键字的SELELCT在student中进展查询.带distinct:Selectclass_id from student不带distinct:selectdistinct class_id from student2. 将teacher表中各教师的某某、教工号与工资按95发放的信息,并将工资按95发放后的列名改为预发工资select teacher_id,teacher_name,salary*0.95 as 预发工资from teacher3. 查询course表中所有学分大于2并且成绩不与格的学生的信息.selectdistinct student.*from student,course,sc where student.student_id=sc.student_id and sc.course_id=course.course_id and course.credit>2 and sc.grade<604. 查询学分在48之间的学生信息.用between.and和复合条件分别实现selectdistinct student.*from student,course,sc where student.student_id=sc.student_id and sc.course_id=course.course_id and course.credit between 4 and 85. 从student_course表中查询出学生为“g9940201,“g9940202的课程号、学生号以与学分,并按学分降序排列用in实现select*from sc,course where student_id in('g9940201','g9940202')and course.course_id=sc.course_id orderby course.credit desc6. 从teacher表中分别检索出姓王的教师的资料,或者某某的第2个字是远或辉的教师的资料select*from teacher where teacher_name like'王%'or teacher_name like'_远%'or teacher_name like'_辉%'7. 查询每个学生与其选修课情况select student_name,course_name from student, sc,course where sc.student_id=student.student_id and sc.course_id=course.course_id8. 以student表为主体列出每个学生的根本情况与其选课情况,如果学生没有选课,只输出其根本情况select student.*,course.*from student join sc on student.student_id=sc.student_idleftjoin courseon course.course_id=sc.course_id9. 查询选修dep04_s001号课程且成绩在80分以上的学生信息。分别用连接,in和exists实现连接:select student.*from sc,student where sc.student_id=student.student_id and sc.course_id='dep04_s001'and sc.grade>80In:select*from student where student_id in(select student_id fromsc where course_id='dep04_s001'and grade>80)exists:select*from student whereexists(select student_id from sc where student.student_id=sc.student_id andcourse_id='dep04_s001'and grade>80)10. 查询所有上计算机根底课程的学生的学号、选修课程号以与分数分别用连接,in和exists实现连接:select sc.*from sc,course where course.course_name='计算机根底'and course.course_id=sc.course_idIn:select student_id,course_id,grade from sc where course_id in(select course_id from course where course_name='计算机根底')exists:select student_id,course_id,grade from sc whereexists(select*from course where course_id=sc.course_id and course_name='计算机根底')11. 查询选修了课程名为“数据库根底的学生学号和某某分别用连接,in和exists实现连接:select student.student_id,student.student_name from sc,student,course where course.course_name='数据库开发技术'and sc.student_id=student.student_id and course.course_id=sc.course_idIn:select student_id,student_name from student where student_id in(select student_id from sc where course_id=(select course_id from course where course_name='数据库开发技术')exists:select student_id,student_name from student whereexists(select*from sc where sc.student_id=student.student_id and sc.course_id=(select course_id from course where course_name='数据库开发技术')12. 查询所有计算机系学生的学号、选修课程号以与分数分别用连接,in和exists实现连接:select sc.*from sc,department,student where department.department_name='计算机科学'and department.department_id=student.department_id and sc.student_id=student.student_idIn:select*from sc where student_id in(select student_id from student where department_id=(select department_id from department where department_name='计算机科学')exists:select*from sc whereexists(select*from student where student.student_id =sc.student_id and student.department_id=(select department_id from department where department_name='计算机科')13查询每个dep_04系学生的总成绩、平均成绩, 仅显示平均成绩与格的学生的记录。select student.student_name ,sum(grade)as 总成绩,avg(grade)as 平均成绩from sc, student,departmentwhere sc.student_id=student.student_id and student.department_id=department.Department_id and department.department_id='dep_04'groupby student.student_id,student_namehavingavg(grade)>6014查询“数据库开发技术的平均成绩selectavg(grade)as 数据库开发平均成绩from sc where course_id in(select course_id from course where course_name='数据库开发技术')15按职称查询教师的平均工资,并按总工资降序排列select profession,avg(salary)as 平均工资,sum(salary)as 总工资from teacher groupby profession orderbysum(salary)desc附录1:教务管理数据库jwgl结构student表结构列名称数据类型长度允许空值说明Student_idChar8否学生学号Student_nameVarchar8否学生某某SexBit1否性别AgeInt4否年龄Class_id Char6否班级号Department_idChar6否系编号Addressvarchar50否家庭住址Course表字段名称数据类型长度允许空说明Course_idChar10否课程号Course_nameVarchar20否课程名称Book_idChar15否书标识SC表字段名称数据类型长度允许空说明Course_idChar10否课程号Student_idVarchar8否学生号gradeTinyint否成绩creditTinyint否学分Teacher表字段名称数据类型长度允许空说明Teacher_idChar9否教师编号Teacher_namenvarchar8否教师某某Department_idChar6否所在系号ProfessionNvarchar16职称SexBit否性别phoneNvarchar15是adressNchar40是住址SalaryNumeric7.2是工资BirthSmalldatetime否出生日期PostalcodeNumeric6,0是 Book表字段名称数据类型长度允许空说明Book_idChar13否书号Book_nameVarchar30否书名Publish_panyVarchar50否Authornvarchar8是作者PriceNumeric5.2是价格Class表字段名称数据类型长度允许空说明Class_idChar6否班级号MonitorVarchar8是班主任某某Class_course表字段名称数据类型长度允许空说明Class_idChar6否班级号Course_idchar10否课程号Department表字段名称数据类型长度允许空说明Department_idChar6否系编号Department_namenvarchar20否系名称

    注意事项

    本文(数据的库1数据的查询.doc)为本站会员(夺命阿水)主动上传,课桌文档仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知课桌文档(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-1

    经营许可证:宁B2-20210002

    宁公网安备 64010402000986号

    课桌文档
    收起
    展开