--1、 查询Student表中的所有记录的Sname、Ssex和Class列。 select Sname,Ssex,Class from Student --3、 查询Student表的所有记录。 select*from Student --4、 查询Score表中成绩在60到80之间的所有记录。 select*from Score where Degree between 60 and 80 --5、 查询Score表中成绩为85,86或88的记录。 select*from Score where Degree like 85 or Degree like 86 or Degree like 88 --6、 查询Student表中“95031”班或性别为“女”的同学记录。 select*from Student where Class='95031' or Ssex='女' --7、 以Class降序查询Student表的所有记录。 select*from Student order by Class desc --8、 以Cno升序、Degree降序查询Score表的所有记录。 select*from Score order by Cno ,Degree desc --9、 查询“95031”班的学生人数。 select count(*)from Student where Class='95031' --10、 查询Score表中的最高分的学生学号和课程号。(子查询或者排序) select *from Score order by Degree select Sno,Cno from Score where Degree in (select MAX(Degree)from Score)
-11、 查询每门课的平均成绩。 select Cno,AVG(degree) from Score group by Cno --12、查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。 select Cno,AVG(degree),count(*) from Score group by Cno having count(*)>=5 and Cno like '3%' --13、查询分数大于70,小于90的Sno列。 select Sno from Score where Degree>70 and Degree<90 --14、查询所有学生的Sname、Cno和Degree列。 select Sname,Cno,Degree from Score,Student where Score.Sno=Student.Sno --15、查询所有学生的Sno、Cname和Degree列。 select Sno,Cname,Degree from Score,Course where Score.Cno=Course.Cno --16、查询所有学生的Sname、Cname和Degree列。 select Sname,Cname,Degree from Score,Course,Student where Score.Cno=Course.Cno and Student.Sno=Score.Sno --17、 查询“95033”班学生的平均分。 select Class,avg(Degree) as 平均分 from Score,Student where Student.Sno=Score.Sno group by Class having Class=95033 --18.现查询所有同学的Sno、Cno和rank列。 select Sno,Cno,rank from Score,grade where Degree between low and upp