接上篇
4、select * from student order by math desc/sak
5、聚合函数
(1)select count(id) from student
select count(*) from student
(2)select sum/avg(math) from student
(3)select max/min(math) from student
(4)select distinct(sex) from student
6、查询每个班级的数学总成绩
select sum(math) from student group by class
查询每个班数学总分大于100分的班级和总分数
select class,sum(math) from math group by class having sum(math)>100
查询每个班级性别为1的数学总分大于100的班级和总分数
select class,sum(math) from student where sex=1 group by class having sum(math)>100
|
|