1、查询教师所有的单位即不重复的Depart列 select distinct depart from teacher 2、查询Score表中成绩在60到80之间的所有记录 select * from score where degree between 60 and 80 3、查询Score表中成绩为85,86或88的记录 select * from score where degree in (85,86,88) 4、查询Student表中“95031”班或性别为“女”的同学记录 select * from student where class='95031' or ssex ='女' 5、以Cno升序、Degree降序查询Score表的所有记录 select * from score order by cno,degree desc 6、查询“95031”班的学生人数 select count(*) from student where class='95031' 或者:select count(*) as scount from student where class='95031' ---查询结果另取列名 为scount 展示 7、查询Score表中的最高分的学生学号和课程号 select sno,cno from score where degree=(select max(degree) from score) 8、查询每门课的平均成绩 select cno,avg(degree) from score group by cno 9、查询Score表中至少有5名学生选修的并以3开头的课程的平均分数 select cno,avg(degree) from score group by cno having count(*)>=5 and cno like'3%' 10、查询所有学生的Sname、Cno和Degree列 select sname,cno,degree from student,score where student.sno=score.sno 或者:select sname,cno,degree from score join student on score.sno = student.sno 11、查询所有学生的Sname、Cname和Degree列 select sname,cname,degree from student,course,score where student.sno = score.sno and score.cno=course.cno 或者:select sname,cname,degree from score join student on student.sno=score.sno join course on score.cno = course.cno |
|