1、(1) 查询性别为“男”的所有学生的名称并按学号升序排列。SELECT SnameFROM StudentsWHERE Ssex=男ORDER BY Sno(2) 查询学生的选课成绩合格的课程成绩,并把成绩换算为积分。积分的计算公式为:1+(考试成绩-60)*0.1*Ccredit。考试成绩=60 否则=0SELECT Sno, Tno, Reports.Cno, Score, Point of Score, CONVERT(FLOAT(1), (Score-60)*0.1*Ccredit+Ccredit)FROM Courses, ReportsWHERE Score=60 AND Repo
2、rts.Cno=Courses.CnoUNIONSELECT Sno, Tno, Reports.Cno, Score, Point of Score, 0FROM Courses, ReportsWHERE Reports.Cno=Courses.Cno AND (Score =3)(10) 查询编号S26的学生所选的全部课程的课程名和成绩。SELECT Courses.Cname,Reports.ScoreFROM Courses,ReportsWHERE Reports.Sno=S26 AND Courses.Cno=Reports.Cno(11) 查询所有选了“数据库原理及其应用”课程
3、的学生编号和姓名。SELECT Sno,SnameFROM StudentsWHERE Sno IN(SELECT Reports.SnoFROM Reports,CoursesWHERE Reports.Cno=Courses.Cno AND Courses.Cname=数据库原理及其应用)(12) 求出至少被两名学生选修的课程编号。SELECT DISTINCT X.CnoFROM Reports X,Reports YWHERE X.Cno=Y.Cno AND X.SnoY.Sno(13) 查询选修了编号S26的学生所选的某个课程的学生编号。SELECT Y.SnoFROM Reports X,Reports YWHERE X.Cno=Y.Cno AND X.Sno=S26/*注:在本题中,如果要求是“查询选修了编号S26的学生所选的某个课程的其他学生编号”时,也就是不包含编号S26学生自身的情况时,在查询条件WHERE中,还需要加上条件X.Sno75(29) 检索“张三”同学不学的课程的课程号SELECT distinct cnofrom Courseswhere cno not in (select Ro from Students, Reports where Students.sno= Reports.sno and Students.sname=张三 )