MySQL作业题及答案hukey

1.查询“生物”课程比“物理”课程成绩高的所有学生的学号

selectA.student_id,sw,wlfrom(SELECTscore.student_id,numberasswfromscoreLEFTJOINcourseonscore.course_id=course.cidwherecourse.cname='生物')asALEFTJOIN(SELECTscore.student_id,numberaswlfromscoreLEFTJOINcourseonscore.course_id=course.cidwherecourse.cname='物理')asBonA.student_id=B.student_idwheresw>wl

2.查询平均成绩大于60分的同学的学号和平均成绩

SELECTstudent_id,avg(number)fromscoreGROUPBYscore.student_idHAVINGavg(number)>60

3.查询所有同学的学号、姓名、选课数、总成绩

SELECTscore.student_id,student.sname,count(score.course_id),sum(number)fromscoreLEFTJOINstudentonscore.student_id=student.sidGROUPBYscore.student_id

4.查询姓“李”的老师的个数

SELECTcount(1)fromteacherwhereteacher.tnamelike'李%'

5.查询没学过“李平老师”课的同学的学号、姓名

SELECTsid,snamefromstudentwherestudent.sidnotin(SELECTDISTINCTscore.student_idfromscorewherescore.course_idin(SELECTcourse.cidfromcourseLEFTJOINteacheroncourse.teacher_id=teacher.tidwhereteacher.tname='李平老师'))

6.查询学过“001”并且也学过编号“002”课程的同学的学号、姓名

SELECTsid,snamefromstudentwherestudent.sidin(SELECTscore.student_idfromscorewherescore.course_id=1orscore.course_id=2GROUPBYscore.student_idHAVINGcount(1)>1);

7.查询学过“李平老师”老师所教的所有课的同学的学号、姓名

SELECTsid,snamefromstudentwherestudent.sidin(SELECTscore.student_idfromscorewherescore.course_idin(SELECTcidfromcourseLEFTJOINteacheroncourse.teacher_id=teacher.tidwhereteacher.tname='李平老师')GROUPBYscore.student_idHAVINGcount(1)=(SELECTcount(1)fromcourseLEFTJOINteacheroncourse.teacher_id=teacher.tidwhereteacher.tname='李平老师'))

8.查询课程编号“002”的成绩比课程编号“001”课程低的所有同学的学号、姓名

SELECTsid,snamefromstudentwherestudent.sidin(selectA.student_idfrom(selectstudent_id,numberasnum_2fromscorewherescore.course_id=2)asALEFTJOIN(selectstudent_id,numberasnum_1fromscorewherescore.course_id=1)asBonA.student_id=B.student_idwhereA.num_2

9.查询有课程成绩小于60分的同学的学号、姓名

SELECTDISTINCTstudent.sid,student.snamefromscoreLEFTJOINstudentonscore.student_id=student.sidwherescore.number<60;

10.查询没有学全所有课的同学的学号、姓名

SELECTsid,snamefromstudentwheresidin(SELECTscore.student_idfromscoreGROUPBYstudent_idHAVINGcount(1)!=(SELECTcount(1)fromcourse))

11.查询至少有一门课与学号为“1”的同学所学相同的同学的学号和姓名

SELECTsid,snamefromstudentwheresidin(SELECTDISTINCTstudent_idfromscorewherescore.course_idin(SELECTcourse_idfromscorewherestudent_id=1))andsid!=1;

12.查询至少学过学号为“1”同学所有课的其他同学学号和姓名*****

SELECTsid,snamefromstudentwheresidin(SELECTstudent_idfromscorewherescore.course_idin(SELECTcourse_idfromscoreWHEREscore.student_id=1)GROUPBYstudent_idHAVINGcount(1)=(SELECTcount(1)fromscoreWHEREscore.student_id=1))

13.查询和“1”号的同学学习的课程完全相同的其他同学学号和姓名

SELECTstudent.sid,snamefromscoreLEFTJOINstudentonscore.student_id=student.sidwherescore.student_idin(SELECTscore.student_idfromscorewherescore.student_id!=1GROUPBYstudent_idHAVINGcount(1)=(SELECTcount(1)fromscorewherescore.student_id=1)andcourse_idin(SELECTcourse_idfromscorewherescore.course_idin(SELECTcourse_idfromscorewherescore.student_id=1)GROUPBYstudent_idHAVINGcount(1)=(SELECTcount(1)fromscorewherescore.student_id=1)))

14.删除学习“叶平”老师课的score表记录

DELETEfromscorewherecourse_idin(SELECTcourse.cidfromcourseLEFTJOINteacheroncourse.teacher_id=teacher.tidwhereteacher.tname='李平老师');

15.向score表中插入一些记录,这些记录要求符合以下条件:①没有上过编号“001”课程的同学学号;②插入“001”号课程的平均成绩

INSERTintoscore(student_id,course_id,number)SELECTsid,1,(SELECTavg(number)fromscorewherescore.course_id=1)fromstudentwherestudent.sidnotin(selectstudent_idfromscorewherescore.course_id=1)

16.按平均成绩从低到高显示所有学生的“生物”、“物理”、“体育”三门的课程成绩,按如下形式显示:学生ID,生物、物理、体育,有效课程数,有效平均分

SELECTsc.student_id,(SELECTavg(number)fromscoreLEFTJOINcourseonscore.course_id=course.cidwherescore.student_id=sc.student_idandcourse.cname='生物')assw,(SELECTavg(number)fromscoreLEFTJOINcourseonscore.course_id=course.cidwherescore.student_id=sc.student_idandcourse.cname='物理')aswl,(SELECTavg(number)fromscoreLEFTJOINcourseonscore.course_id=course.cidwherescore.student_id=sc.student_idandcourse.cname='体育')asty,count(sc.course_id),avg(sc.number)asavg_nfromscorescGROUPBYsc.student_idORDERBYavg_nasc;

17.查询各科成绩最高和最低的分:以如下形式显示:课程ID,最高分,最低分

selectcourse_id,max(number),min(number)fromscoreGROUPBYcourse_id

18.按各科平均成绩从低到高和及格率的百分数从高到低顺序

SELECTscore.course_id,avg(number)asavg_n,(sum(casewhenscore.number>60then1else0end)/count(1)*100)aspercentfromscoreGROUPBYscore.course_idORDERBYavg_nasc,percentdesc;

19.课程平均分从高到低显示(现实任课老师)

SELECTscore.course_id,avg(score.number)asavg_n,teacher.tnamefromscoreLEFTJOINcourseonscore.course_id=course.cidLEFTJOINteacheroncourse.teacher_id=teacher.tidGROUPBYscore.course_idORDERBYavg_ndesc;

20.查询各科成绩前三名的记录:(不考虑成绩并列情况)

SELECTsc.course_id,(SELECTnumberfromscorewherescore.course_id=sc.course_idORDERBYnumberdesclimit0,1)asfirst_num,(SELECTnumberfromscorewherescore.course_id=sc.course_idGROUPBYnumberORDERBYnumberdesclimit1,1)assecond_num,(SELECTnumberfromscorewherescore.course_id=sc.course_idGROUPBYnumberORDERBYnumberdesclimit2,1)asthird_numfromscorescGROUPBYsc.course_id

21.查询每门课程被选修的学生数

SELECTcourse_id,count(student_id)fromscoreGROUPBYcourse_id

22.查询出只选修了一门课程的全部学生的学号和姓名

SELECTstudent.sid,student.snamefromscoreLEFTJOINstudentonscore.student_id=student.sidGROUPBYstudent_idHAVINGcount(score.course_id)=1;

23.查询男生、女生的人数

SELECT*from(SELECTcount(1)asboyfromstudentwherestudent.gender='男')asA,(SELECTcount(1)asgirlfromstudentwherestudent.gender='女')asB

24.查询姓“张”的学生名单

SELECT*fromstudentwherestudent.snamelike'张%'

25.查询同名同姓学生名单,并统计同名人数

SELECTsname,count(sname)fromstudentGROUPBYsnameHAVINGcount(1)>1;

26.查询每门课程的平均成绩,结果按平均成绩升序排列,平均成绩相同时,按课程号降序排列

SELECTcourse_id,avg(number)asavg_nfromscoreGROUPBYcourse_idORDERBYavg_nasc,course_iddesc;

27.查询平均成绩大于80的所有学生的学号、姓名和平均成绩

SELECTscore.student_id,student.sname,avg(number)fromscoreLEFTJOINstudentonscore.student_id=student.sidGROUPBYstudent_idHAVINGavg(number)>80;

28.查询课程名称为“生物”,且分数低于60的学生姓名和分数

SELECT*fromscoreLEFTJOINstudentonscore.student_id=student.sidwherescore.number<60andscore.course_idin(SELECTcidfromcoursewherecourse.cname='生物')

29.查询课程编号为003且课程成绩在80分以上的学生的学号和姓名

SELECTstudent.sid,student.snamefromscoreLEFTJOINstudentonscore.student_id=student.sidwherescore.course_id=3andscore.number>80;

30.求选了课程的学生人数

SELECTcount(DISTINCTstudent_id)fromscorewherescore.course_idisnotnull;

31.查询选修刘海燕老师所授课程的学生中,成绩最高的学生姓名及其成绩

SELECTstudent.sname,max(score.number)fromscoreLEFTJOINstudentonscore.student_id=student.sidwherescore.course_idin(SELECTcidfromcourseLEFTJOINteacheroncourse.teacher_id=teacher.tidwhereteacher.tname='刘海燕老师')

32.查询各个课程及相应的选修人数

SELECTcourse_id,count(1)fromscoreGROUPBYcourse_id

33.查询不同课程但成绩相同的学生的学号、课程号、学生成绩

SELECTDISTINCTs1.course_id,s2.course_id,s1.number,s2.numberfromscoreass1,scoreass2wheres1.number=s2.numberands1.course_id!=s2.course_idorderbys1.course_id

34.查询每门课程成绩最好的前两名

SELECTsc.course_id,(SELECTnumberasf_nfromscorewherecourse_id=sc.course_idORDERBYnumberdesclimit0,1)asfirst_num,(SELECTnumberasf_nfromscorewherecourse_id=sc.course_idGROUPBYnumberORDERBYnumberdesclimit1,1)assecond_numfromscorescGROUPBYsc.course_id

35.检索至少选修两门课程的学生学号

SELECTstudent_id,count(1)fromscoreGROUPBYstudent_idHAVINGcount(1)>1;

36.查询全部学生都选修的课程的课程号和课程名

SELECTscore.course_id,course.cnamefromscoreLEFTJOINcourseonscore.course_id=course.cidGROUPBYcourse_idHAVINGcount(1)=(SELECTcount(1)fromstudent)

37.查询没学过李平老师讲授的任一门课程的学生姓名

SELECTsid,snamefromstudentwheresidnotin(SELECTDISTINCTstudent_idfromscorewherescore.course_idin(SELECTcidfromcourseLEFTJOINteacheroncourse.teacher_id=teacher.tidwhereteacher.tname='李平老师'))

38.查询两门以上不及格课程的同学的学号及其平均成绩

SELECTsc.student_id,(SELECTavg(number)fromscorewherescore.student_id=sc.student_id)asavg_nfromscorescwheresc.number<60GROUPBYstudent_idHAVINGcount(1)>1;

39.检索“004”课程分数小于60,按分数降序排列的同学学号

SELECTstudent_idfromscorewherescore.course_id=4andscore.number<60ORDERBYscore.numberdesc;

40.删除“002”同学的“001”课程的成绩

DELETEfromscorewherescore.student_id=2andscore.course_id=1;

THE END
1.查答案的作业软件排行榜前十名偏玩手游盒子分享十大查答案的作业软件排行榜前十名手机应用,编辑为您推荐手机查答案的作业软件排行榜第一名到前5名到前十名的应用。找查答案的作业软件有哪些、查答案的作业软件哪个好用,上偏玩手游盒子https://m.pianwan.com/s/zj-1480152
2.什么软件可以查答案APP推荐什么软件可以查答案下载豌豆荚什么软件可以查答案榜单为您提供最新什么软件可以查答案大全,这里不仅有什么软件可以查答案安卓版本APP、历史版本应用下载资源,还有类似什么软件可以查答案的应用推荐,欢迎大家前来豌豆荚下载。https://www.wandoujia.com/bangdan/405929/
3.什么软件最好?扫码搜答案的软件全书答案找答案的最好软件是什么?来绿色资源网看看吧!小编整理了搜作业答案的软件、搜完整卷子答案的软件、扫二维码搜答案的软件等各种搜答案神器!免费拍照搜题秒出答案,寒假作业、暑假作业、试卷轻松搞定,学习必备利器!http://m.downcc.com/k/soudaanruanjian
4.搜题答案神器APP下载查作业答案神器搜作业答案神器现在中小学的数学题目难度都非常大,很多时候需要一些搜题答案神器来帮忙,有了查作业答案神器不管是家长还是学生就可以快速的对作业进行检查,找到正确的题目和答案,并且对解题思路进行学习,让用户更高效率的http://www.kkx.net/zt/72528.html
5.查询寒假作业答案的软件有哪些查询寒假作业答案的软件推荐【查询寒假作业答案的软件】每当寒暑假来临时,学生们也会拥有快乐寒暑假的作业,这些作业本上的答案大部分老师为了让学生们可以自己写,都要求学生们撕下来上交。那么写作业时遇到不会写的题目应该怎么办呢?这就需要我们今天带来的软件的,帮助用户们快速查询到题目的答案,并且还有解题过程,方便用户们举一反三。https://www.nwmie.com.cn/ztsoft/cxhjzydadrj/
6.2024搜暑假作业答案的软件大全暑假作业答案软件有哪些?很多小伙伴面对较多的暑假作业的难题,不知道该如何解答,这里为大家整理了一些可以查暑假作业答案软件,用户只需要通过扫一扫就可以轻松查询到结果,有着精准详细的答案,让大家可以轻松完成作业,有需要的朋友快来下载吧! 展开全部 作业帮一对一辅导 生活实用 | 117.68M 辅导作业的软件 暑假作业答http://m.doyo.cn/zhuanti/sjzydarj/
7.扫条码出整本答案app扫码得答案的软件下载扫码查答案app专题有哪些好用的软件呢?比如常见的作业帮、小猿搜题、爱作业等等,这些软件只需要对准题目在线搜一搜就能为你提供正确答案以及标准解析!你是否总是因为老师布置作业太难而无法完成学业?是否会因为作业太多而产生厌学心理?当你产生以上情绪时,可以来本专题看看有哪些扫码出答案的app,它能轻松帮助你完成作业https://www.itmop.com/key/smcdadapp/
8.章节:一扫条形码出整本作业答案的软件下载,扫一扫条形码查价格吾爱小说网提供了创作的精彩小说《我在世间强无敌》文字章节:一扫条形码出整本作业答案的软件下载,扫一扫条形码查价格查询,什么软件可以扫码搜答案,免费在线阅读!http://www.rebloga.com/chapter/MJAWXuSq.html
9.国家开放大学22秋药学信息检索形考任务[标准答案]国家开放大学22秋药学信息检索形考任务[标准答案] 1.PubMed-主题检索(10分)试卷总分:1 得分:100 1.上述模拟检索的检索结果,实际执行的是以下哪个检索式的检索结果? A."Osteotomy" AND "Kyphosis" B."Osteotomy" [Mesh] AND "Kyphosis" [Mesh] C. 奥鹏各院校作业答案、国开形考作业答案、各网院作业答案,:http://www.youxue100f.com/qita/2022-12-05-10096.html
10.大学生搜题软件哪个好?2020搜题软件排行榜众课帮和作业帮的区别小猿搜题是一款为学生准备的作业软件,通过小猿搜题app你可以通过手机拍照来便捷的找到你想要的解题思路、解题过程以及解题方法等等,让你拥有一个私人老师,快速的完成作业。 软件特色: 1、拍照即得答案解析,无需注册,永久免费。 2、典型题目由名师视频讲解,学得更轻松。 https://blog.csdn.net/sifogp/article/details/109119174
11.快对作业怎么查答案,快对作业怎么拍题解答拍照搜题功能已经成为了很多家长辅导作业的必备神器,现在有越来越多类似软件出现,这些软件都有自己独特的功能和自己独特的使用方法,很多家长都想知道快对作业怎么查答案,快对作业怎么拍题解答呢?下面跟着小编一起来看看吧。 1、可以在快对作业的首页,添加自己常用的书籍的版本、年级、科目就可以查询答案,以后每一次查询https://www.haoyunbb.com/baike/13/133330.html
12.快对作业怎么找报纸答案快对作业查找报纸答案教程快对作业APP中为用户提供了报纸答案,有需要的小伙伴可以通过这个平台来查询相关的报纸答案资料,非常的不错。那么下面小编就来为大家介绍一下在快对作业APP中查找报纸答案的方法。 快对作业怎么找报纸答案? 1、点击打开快对作业app,点击页面最上方的搜索框。 https://shouyou.3dmgame.com/gl/165763.html
13.www.jxmzxx.com/appnews这下可好何家的"王位争夺战"瞬间打响,比《权力的游戏》还要精彩纷呈。 最后二房的何超琼凭借自己的商业嗅觉,成功登上了"赌王宝座"。 但是坐上这个位置可不是请客吃饭那么简单。 家族内部的明争暗斗,简直堪比"宫斗剧"的巅峰之作。 你来我往尔虞我诈,每天都在上演着"步步惊心"。 http://www.jxmzxx.com/appnews_20241103/08616420
14.远程学习试题含答案及方法返回课程作业列表,点开查询结果按钮,如果能看到自己提交的作业答案内容则表示作业提交成功,作业提交后任课教师会定期给予批复给出相应的作业分数。 3.如何查看平台里的通知公告? 登录东北农业大学继续教育中心网站首页:,在右侧用户登录处输入用户名和密码(均为学号), 点击“登录”按钮,进入网络教学平台,按照进入平台方法https://www.ruiwen.com/shiti/1504644.html
15.知识竞赛答题软件学党史答题竞赛活扫一扫作业出答案的软件扫一扫作业出答案 “礼赞新时代 奋进新征程”主题教育线上答题活动,,开展“学思想、强党性、重实践、建新功”主题教育知识线上答题活动。为深入开展学习新思想主题教育,激发和调动广大党员、干部职工的学习热情和主动性,促进真学真懂、笃信笃行,结合实际,在持续加强线下学习的同时,积极组织开展主题教育应知应会知识线http://www.xwykj.com/details/50991.html
16.查试卷答案的app软件大全查试卷答案的app推荐下载PP助手为您提供查试卷答案的app有哪些大全推荐,在这里我们为您提供查试卷答案的app有哪些软件下载资源,查试卷答案的app有哪些安卓版本、官方版本&老版本下载地址合集,还可查阅相关查试卷答案的app有哪些攻略大全,欢迎到PP助手下载。https://wap.pp.cn/topic/1327422/