




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第1关:计算每个班的语文总成绩和数学总成绩----------禁止修改----------dropdatabaseifexistsmydbcascade;----------禁止修改--------------------begin-------------创建mydb数据库createdatabaseifnotexistsmydb;---使用mydb数据库usemydb;---创建表scorecreatetableifnotexistsscore(namestringcomment'姓名',chinesestringcomment'语文成绩',mathsstringcomment'数学成绩')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step1_files/score.txtloaddatalocalinpath'/root/data/step1_files/score.txt'intotablescore;--创建表classcreatetableifnotexistsclass(stunamestringcomment'姓名',classnamestringcomment'所在班级')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step1_files/class.txtloaddatalocalinpath'/root/data/step1_files/class.txt'intotableclass;--计算每个班的语文总成绩和数学总成绩,要求有哪科低于60分,该名学生成绩不计入计算。selectt1.classname,t1.chinese,t2.mathsfrom(selectc.classnameclassname,sum(s.chinese)chinesefromclassc,scoreswherec.stuname=ands.chinese>=60groupbyc.classname)t1,(selectc.classnameclassname,sum(s.maths)mathsfromclassc,scoreswherec.stuname=ands.maths>=60groupbyc.classname)t2wheret1.classname=t2.classname;----------end----------第2关:查询选修了3门以上的课程的学生姓名----------禁止修改----------dropdatabaseifexistsmydbcascade;----------禁止修改--------------------begin-------------创建mydb数据库createdatabaseifnotexistsmydb;---使用mydb数据库usemydb;---创建表my_stucreatetableifnotexistsmy_stu(idstringcomment'学生id',namestringcomment'学生姓名',sexstringcomment'性别',agestringcomment'年龄',colstringcomment'所选的系')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step2_files/my_student.txtloaddatalocalinpath'/root/data/step2_files/my_student.txt'intotablemy_stu;--创建表my_scorecreatetableifnotexistsmy_score(idstringcomment'学生id',courseidstringcomment'课程id',scorestringcomment'成绩')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step2_files/my_score.txtloaddatalocalinpath'/root/data/step2_files/my_score.txt'intotablemy_score;--创建表my_coursecreatetableifnotexistsmy_course(courseidstringcomment'课程id',coursenamestringcomment'课程名称')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step2_files/my_course.txtloaddatalocalinpath'/root/data/step2_files/my_course.txt'intotablemy_course;---查询选修了3门以上的课程的学生姓名。select,t.coursenumfrom(selectid,count(courseid)coursenumfrommy_scoregroupbyid)t,my_stustuwheret.coursenum>=3andstu.id=t.id;----------end----------第3关:课程选修人数----------禁止修改----------dropdatabaseifexistsmydbcascade;----------禁止修改--------------------begin-------------创建mydb数据库createdatabaseifnotexistsmydb;---使用mydb数据库usemydb;---创建表my_stucreatetableifnotexistsmy_stu(idstringcomment'学生id',namestringcomment'学生姓名',sexstringcomment'性别',agestringcomment'年龄',colstringcomment'所选的系')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step2_files/my_student.txtloaddatalocalinpath'/root/data/step2_files/my_student.txt'intotablemy_stu;--创建表my_scorecreatetableifnotexistsmy_score(idstringcomment'学生id',courseidstringcomment'课程id',scorestringcomment'成绩')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step2_files/my_score.txtloaddatalocalinpath'/root/data/step2_files/my_score.txt'intotablemy_score;--创建表my_coursecreatetableifnotexistsmy_course(courseidstringcomment'课程id',coursenamestringcomment'课程名称')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step2_files/my_course.txtloaddatalocalinpath'/root/data/step2_files/my_course.txt'intotablemy_course;---查询每个课程有多少人选修。selectt2.coursename,count(*)from(selectname,course.coursenamecoursenamefrom(selectname,score.courseidcourseidfrommy_scorescore,my_stustuwherescore.id=stu.id)t1,my_coursecoursewheret1.courseid=course.courseid)t2groupbyt2.coursename;----------end----------第4关:shujuku课程的平均成绩----------禁止修改----------dropdatabaseifexistsmydbcascade;----------禁止修改--------------------begin-------------创建mydb数据库createdatabaseifnotexistsmydb;---使用mydb数据库usemydb;---创建表my_stucreatetableifnotexistsmy_stu(idstringcomment'学生id',namestringcomment'学生姓名',sexstringcomment'性别',agestringcomment'年龄',colstringcomment'所选的系')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step2_files/my_student.txtloaddatalocalinpath'/root/data/step2_files/my_student.txt'intotablemy_stu;--创建表my_scorecreatetableifnotexistsmy_score(idstringcomment'学生id',courseidstringcomment'课程id',scorestringcomment'成绩')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step2_files/my_score.txtloaddatalocalinpath'/root/data/step2_files/my_score.txt'intotablemy_score;--创建表my_coursecreatetableifnotexistsmy_course(courseidstringcomment'课程id',coursenamestringcomment'课程名称')rowformatdelimitedfieldsterminatedby','storedastextfile;---导入数据:/root/data/step2_files/my_course.txtloaddatalocalinpath'/root/data/step2_files/my_course.txt'intotablemy_course;---计算shujuku课程的平均成绩。selectt3.coursename,t2.avg_s
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 公司软件权限管理制度
- 律师拆迁方案模板(3篇)
- 住宅租赁安全责任及维护管理协议
- 拆迁安置房购置及装修改造工程合同
- 拆迁个人房产产权转移与补偿协议
- 藏式风格民宿客房装修合同
- 工业地产厂房买卖合同范本(含土地使用)
- 农业机械化采棉机驾驶员劳务合同
- 知名餐饮品牌连锁店面转租合同范本
- 车贷贷款逾期罚息及违约金协议
- 2025年铁路列车员(初级)职业技能鉴定参考试题库(含答案)
- 浙江省杭州市2025届高三下学期二模试题 数学 含答案
- 2025年初中语文名著阅读《林海雪原》故事梗概
- 2025年中石化中原石油工程有限公司钻井工程技术研究院-企业报告(业主版)
- UHPC材料特性与应用技术解析
- 2024年四川内江中考满分作文《我也有自己的光芒》8
- 强制执行申请书电子版
- 金融科技概论 章习题及答案 第1-8章
- 笔杆上橡胶套的作用(教学设计)-科学三年级下册人教鄂教版
- 低压电气基础知识培训电工-电气工程师
- 2025年江苏盐城市海兴集团有限公司招聘笔试参考题库含答案解析
评论
0/150
提交评论