




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 国家电工安全知识考试题库及答案解析
- 金属材料安全员考试题库及答案解析
- 交安证安全培训试题及答案解析
- 货币乘数 证券从业考试及答案解析
- 护理抢救车管理试题库及答案解析
- 内科护理学题库按章节及答案解析
- 2025终止租房合同通知范本
- 2025解除劳动合同证明范本
- 期货从业考试期货基础及答案解析
- 车牌协议书合同
- 2025年杭州上城区总工会公开招聘工会社会工作者9人笔试参考题库附答案解析
- 2025年互联网+特殊教育行业研究报告及未来发展趋势预测
- 医院信息安全保密培训课件
- 物流紧急事件应急预案方案
- 幼儿创意玉米课件
- 2025年智能焊接机器人产业发展蓝皮书-GGII高工咨询
- 冷却塔填料更换施工方案
- 运输公司环保措施方案(3篇)
- 2025安全月八大特殊作业竞赛题库及答案
- 医疗机构基孔肯雅热防控卫生监督检查表
- 刀具更换管理办法
评论
0/150
提交评论