摘要:
检索至少选修两门课程的学生学号 SELECT Student.SId,Student.Sname,选课数 from Student, (SELECT sid,COUNT(cid) 选课数 from sc GROUP BY sid HAVING COUNT(cid)>=2) t WHERE Stude 阅读全文
摘要:
查询不同课程成绩相同的学生的学生编号、课程编号、学生成绩 select a.cid, a.sid, a.score from sc as a,sc as b WHERE a.sid = b.sid and a.cid != b.cid and a.score = b.score group by a 阅读全文
摘要:
查询选修「张三」老师所授课程的学生中,成绩最高的学生信息及其成绩 方式1: SELECT Student.sid,Student.sname,t.score from Student , (SELECT TOP 1 * from sc WHERE CId = (SELECT CId from Tea 阅读全文
摘要:
求每门课程的学生人数 SELECT cid,COUNT(cid) 课程人数 from sc GROUP BY cid 阅读全文
摘要:
查询课程编号为 01 且课程成绩在 80 分以上的学生的学号和姓名 SELECT Student.SId,Student.Sname,Cname,score from Student,Course,SC WHERE Student.SId = sc.SId AND Course.CId = SC.C 阅读全文
摘要:
查询不及格的课程 SELECT * from Course WHERE CId IN (SELECT cid from sc WHERE score < 60 GROUP BY cid) 阅读全文
摘要:
查询任何一门课程成绩在 70 分以上的姓名、课程名称和分数 SELECT Sname,cname,Course.CId,SC.score from Student,Course,sc WHERE Student.SId = SC.SId AND Course.CId = SC.CId AND sco 阅读全文
摘要:
查询所有学生的课程及分数情况(存在学生没成绩,没选课的情况) SELECT Student.*,CId,score from Student LEFT JOIN SC ON Student.SId = SC.SId 阅读全文
摘要:
查询课程名称为「数学」,且分数低于 60 的学生姓名和分数 SELECT Student.Sname,Course.Cname,SC.score FROM Student,Course,SC WHERE Student.SId = SC.SId AND Course.CId = sc.cid AND 阅读全文
摘要:
查询平均成绩大于等于 85 的所有学生的学号、姓名和平均成绩 SELECT Student.SId,Student.Sname,平均成绩 FROM Student , (SELECT sid,AVG(score) 平均成绩 from sc GROUP BY SId HAVING AVG(score) 阅读全文
摘要:
查询每门课程的平均成绩,结果按平均成绩降序排列,平均成绩相同时,按课程编号升序排列 SELECT cid,AVG(score) 平均成绩 from sc GROUP BY cid ORDER BY AVG(score) DESC,cid 阅读全文
摘要:
查询 1990 年出生的学生名单 --方式1 SELECT * FROM Student WHERE Sage BETWEEN '1990-01-01' AND '1990-12-31' --方式2 SELECT * FROM Student WHERE YEAR(Sage)=1990 阅读全文
摘要:
查询同名学生名单,并统计同名人数 SELECT sname,COUNT(sname) 同名人数 from Student GROUP BY sname HAVING COUNT(sname)>1 阅读全文
摘要:
查询名字中含有「风」字的学生信息 SELECT * from Student WHERE Sname like '%风' or Sname LIKE '风%' or Sname LIKE'%风%' 阅读全文
摘要:
查询男生、女生人数 SELECT Ssex,COUNT(Ssex) 人数 from Student GROUP BY Ssex 阅读全文
摘要:
查询出只选修两门课程的学生学号和姓名 --方式1: SELECT Student.SId,Sname from Student WHERE SId in ( SELECT sid from sc GROUP BY SId HAVING COUNT(cid)=2 ) --方式2 SELECT Stud 阅读全文
摘要:
查询每门课程被选修的学生数 SELECT cid,COUNT(cid) 选修人数 from sc GROUP BY cid 阅读全文
摘要:
查询各科成绩前三名的记录 select a.sid,a.cid,a.score from sc a left join sc b on a.cid = b.cid and a.score<b.score group by a.cid, a.sid,a.score having count(*)<3 阅读全文
摘要:
统计各科成绩各分数段人数:课程编号,课程名称,[100-85],[85-70],[70-60],[60-0] SELECT Course.CId,Course.Cname ,t.[0-60],t.[60-70],t.[70-85],t.[85-100] from Course, ( SELECT c 阅读全文
摘要:
按各科成绩进行排序,并显示排名, Score 重复时保留名次空缺 SELECT t.cid,t.sid,t.score ,COUNT(t1.score)+1 as 排名 from sc as t LEFT JOIN SC as t1 ON t.cid = t1.CId AND t.score < t 阅读全文