查询student表中的所有记录
select * from student
检查student表中的所有记录的sname,Ssex和class
select sname,ssex,class from student
查询老师所有的单位即不重复的depart列
select distinct depart from teacher;
查询socre表中成绩在从68到80之间的记录
select * from score where degree between 60 and 80;
查询score表成绩中为85、86或88
select * from score where degree in(85,86,88)
查询student表中“95031”班或性别为“女”同学的同学记录
select * from student where class=“95031” or ssex=“女”
以class降序查询student表的所有记录
select * from student order by class desc
以cno升序。degree降序查询score表的所有记录
select *from score order by cno asc,degree desc
查询“95031”班学生人数
select count(*) from student where class=“95031”
查询score表中的最高分的学生学号和课程号(子查询或者排序)
select sno,cno from score where degree=(select max(degree) from score)
select sno,cno from score order by degree desc limit 0,1
.查看每门课的平均成绩 (分组查询)
select avg(degree) from score where cno=“3-105”
…
查询score表中至少有2名同学选修的并以3开头的课程的平均分数 havimg(组级过滤)
select cno,avg(degree),count(*) from score
group by cno having count(cno)>=2 and cno like ‘3%’;