版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 福建省事业单位招录行政职业能力测验(数学运算)模拟试卷1
- 人教版六年级下册数学总复习导学案
- 五年级下册英语教案-Module 3 Unit 6第2课时教科版(广州深圳)
- BeanShell快速入门Java应用
- 2024年四川省宜宾市中考英语试题及答案
- 中兴智慧城市智慧旅游之秦皇岛智慧旅游信息图
- 2020年小程序平台商业化分析
- 2022年度辽宁省安全员之C证(专职安全员)练习题(五)及答案
- 2022年度辽宁省安全员之B证(项目负责人)考前自测题及答案
- 2022年度辽宁省安全员之A证(企业负责人)能力测试试卷A卷附答案
- 小型预制构件厂临建方案5.02
- 农业企业经营管理学试卷
- 2023华科就业质量报告
- 2022北京中考真题道德与法治试卷含答案
- 积极心理学:塑造刚健自信的中国青年智慧树知到课后章节答案2023年下上海思博职业技术学院
- 2023年健康照护师(初级)理论知识考核试题
- 愚公移山英文 -中国故事英文版课件
- 初三综合素质评价自我陈述报告(16篇)
- 广东省汕头市金平区2022-2023学年七年级下学期期末语文试题
- 档案法知识竞赛试题及答案
- 陕西省地图含市县地图矢量分层地图模板课件
评论
0/150
提交评论