合计/统计函数
count函数
select count(*) from student;
select count(*) from student where math > 90;
- count(*)和count(列)的区别
- count(*)返回满足条件的记录的行数
- count(列)统计满足条件的某列有多少个,但是会排除为null
sum函数
- sum函数仅对数值有作用,否则会报错
- 对于多列求和 , 不能少。
select sum(math) from student;
select sum(english),sum(math),sum(chinese) from student;
select sum(english+math+chinese) from student;
select sum(chinese) / count(*) from student;
avg函数
select avg(math) from student;
select avg(math + english + chinese) from student;
max/min函数
select max(math + english + chinese) , min(math + chinese + english) from student;
select max(math),min(math) from student;