语句题目及答案.doc

语句题目及答案.doc

ID:58631402

大小:83.00 KB

页数:5页

时间:2020-10-17

语句题目及答案.doc_第1页
语句题目及答案.doc_第2页
语句题目及答案.doc_第3页
语句题目及答案.doc_第4页
语句题目及答案.doc_第5页
资源描述:

《语句题目及答案.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、/*Student(S#,Sname,Sage,Ssex)学生表Course(C#,Cname,T#)课程表SC(S#,C#,score)成绩表Teacher(T#,Tname)教师表*/--1、查询“001”课程比“002”课程成绩高的所有学生的学号;selects1.s#fromSCs1,SCs2wheres1.s#=s2.s#ands1.c#='001'ands2.c#='002'ands1.score>s2.score;--2、查询平均成绩大于60分的同学的学号和平均成绩;selects.s#,avg(s.score)fromSCsgroupbys.s#havingav

2、g(s.score)>60;--3、查询所有同学的学号、姓名、选课数、总成绩;selectd.s#,max(d.sname),count(distincts.c#),sum(s.score)fromStudentd,SCswhered.s#=s.s#groupbyd.s#;--4、查询姓“李”的老师的个数;selectcount(0)fromTeachertwheret.tnamelike'李%';--5、查询没学过“叶平”老师课的同学的学号、姓名;selectd.s#,d.snamefromStudentdwherenotexists(selectdistinct(s.s#)

3、fromSCs,Teachert,Coursecwheret.t#=c.t#ands.c#=c.c#andt.tname='叶平'andd.s#=s.s#);--6、查询学过“001”并且也学过编号“002”课程的同学的学号、姓名;selectd.s#,d.snamefromStudentd,SCswheres.s#=d.s#ands.c#='001'andexists(selects1.s#fromSCs1wheres1.s#=s.s#ands1.c#='002');--7、查询学过“叶平”老师所教的所有课的同学的学号、姓名;selects.s#,max(d.sname)fr

4、omSCs,Studentd,Coursec,Teachertwheres.s#=d.s#ands.c#=c.c#andc.t#=t.t#andt.tname='叶平'groupbys.s#havingcount(distincts.c#)=(selectcount(0)fromCoursec,Teachertwherec.t#=t.t#andt.tname='叶平');--8、查询课程编号“002”的成绩比课程编号“001”课程低的所有同学的学号、姓名;selectd.s#,d.snamefromSCs1,SCs2,Studentdwheres1.s#=s2.s#ands1.

5、s#=d.s#ands1.c#='002'ands2.c#='001'ands1.score

6、groupbys.s#havingcount(distincts.c#)<>(selectcount(0)fromCourse);--11、查询至少有一门课与学号为“1001”的同学所学相同的同学的学号和姓名;selectdistincts.s#,d.snamefromStudentd,SCswhered.s#=s.s#ands.s#<>'1001'andexists(selects1.c#fromSCs1wheres1.s#='1001'ands.c#=s1.c#);--12、查询至少学过学号为“1010”同学所有一门课的其他同学学号和姓名;selectdistincts.s

7、#,d.snamefromStudentd,SCswhered.s#=s.s#ands.s#<>'1010'ands.c#in(selects1.c#fromSCs1wheres1.s#='1010');--13、把“SC”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩;updateSCssets.score=(selectavg(s1.score)fromSCs1wheres.c#=s1.c#)whereexists(selects.c#fromCoursec,Teachertwhe

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。