group by :select 分组字段,聚合函数 from 表名 where 条件 group by 分组字段 having 过滤条件
select cno,avg(degree) from score group by cno
12、查询Score表中至少有5名学生选修的并以3开头的课程的平均分数。
having是跟在 group by之后的筛选条件 like''是模糊查询 ''中的%是任意字符数的通配符,-是单个字符数的通配符
select cno,avg(degree) from score group by cno having cno like'3%'and count(1)>=5
13、查询分数大于70,小于90的Sno列。
between 较小值 and 较大值
select sno from score where degree between 70 and 90
15、查询所有学生的Sno、Cname和Degree列。
join on 多表之间的关联关系
select s.sno,c.cname , s.degree from score s join course c on s.cno=c.cno
16、查询所有学生的Sname、Cname和Degree列。
select s.sname,c.cname, e.degree from student s,score e, course c where s.sno = e.sno and e.cno = c.cno
select s.sname,c.cname, e.degree from student s join score e on s.sno = e.sno join course c on e.cno =c.cno
17、 查询“95033”班学生的平均分。
select avg(degree) from score e join student s on e.sno = s.sno where sclass='95033'