sql">-- 统计每个班级 期末成绩的最高分select GName,max(SCScore3) Max
from student,sc,grade
where student.SId=sc.SId
and student.GId=grade.GId
groupby GName-- 依据输出样例分析 需要的表-- 多表连接、等值连接
10-121 显示没有班导师的班级名称、院系名称
sql">select GName,DName
from grade
leftjoin dept on grade.DId=dept.DId
where TId <=>null-- 筛选符合输出样例的表-- 以grade表为主,若TId为空则表示没有班导师
sql">selectdistinct course.cno,cname
from teachers,teaching,course
where teachers.tno=teaching.tno
and teaching.cno=course.cno
and tsex='女'-- distinct 去重!!!
10-133 检索出students表、sc表中至少选修2门课程的女生姓名
sql">select sname
from students
where sno in(select snofrom scgroupby snohavingcount(cno)>=2)and ssex ='女'-- 审题!!!
sql">select students.sno,sname,cno,score
from students
leftjoin sc on students.sno=sc.sno-- 将students 作为主表
10-136 检索出students表和sc表中没有选课的学生学号和姓名
sql">-- select sno,sname-- from students-- where sno not in (-- select sno -- 1.查询选了课的学生-- from sc-- )-- 没有选课的学生select students.sno,sname
from students
leftjoin sc on students.sno=sc.sno
where cno <=>null-- 将students表作为主表连接,cno = null为没有选课
10-137 检索出students表和sc表中“19信管2”班的学生所选修的课程号
sql">select cno
from students,sc
where students.sno=sc.sno
and class='19信管2'
10-138 检索出students表和sc表中“陈晓东”同学所选课程的课号及成绩
sql">select cno,score
from students,sc
where students.sno=sc.sno
and sname='陈晓东'
10-139 检索出students表中出生日期大于所有女同学出生日期的男同学的姓名及系别
sql">-- 出生日期 大于所有女同学出生日期 的男同学 的姓名及系别-- select distinct sname,sdept-- from students-- where bday > all(-- select bday-- from students-- where ssex='女'-- )-- and ssex='男'select sname,sdept
from students
where bday >(selectmax(bday)from studentswhere ssex='女')and ssex='男'-- 大于所有 或者 比最大的都大
10-140 检索出students表、sc表中信息学院女学生的学生学号、姓名、课号及考试成绩。
sql">select sc.sno,sname,cno,score
from students,sc
where students.sno=sc.sno
and sdept='信息学院'and ssex='女'
sql">selectdistinct cname
from teachers
join teaching on teachers.tno=teaching.tno
join course on teaching.cno=course.cno
where tname='王珊'-- distinct !!!
10-143 查询所授每门课程平均成绩均在70分以上的教师(MSSQL)
sql">select CNO cno
from sc
groupby CNO
havingavg(GRADE)>70-- 1.先处理sc表-- 平均成绩大于70的cno
10-144 检索Student表中与‘张三’在同一个专业的学生记录(MSSQL字符匹配)
sql">selectdistinct sno 学号,sname 姓名
from stu
where mno in(select mno-- 1.查询张三的专业from stuwhere sname = N'张三')-- and not sname = N'张三'-- and sname <> N'张三'and sname != N'张三'-- MSSQL字符串赋值,需要在字符串前面加 N
“Girls mature earlier than boys,” she says. “They hit rapid growth at 11, 12, whereas boys hit it about 13. Once you hit ‘peak height velocity’, training should concentrate on the structural side, push strength and muscle development. Girls are missin…