系列文章
mysql之select,insert,delete,update
count
计数,经常和group by语句搭配使用,此时,可以这样理解,分组后,该分组的个数。还以之前的数据表tb_student为例。
1、计算同一天入学的学生个数。
use school;
-- 计算同一天入学的学生个数。
select count(1) as `count` ,date(createdate) as goSchoolDate from tb_student group by date(createdate);
MAX
1、最大的id
1 use school;
2 select max(id) from tb_student;
Min
1、最小id
use school;
select min(id) from tb_student;
SUM
1、求出所有学生的年龄和
use school;
select sum(age) from tb_student;
AVG
1、求所有学生的年龄平均值
use school;
select avg(age) from tb_student;
celing
celing翻译过来就是“天花板”的意思,意思就是,不管小数点后面是什么,就往上进位。比如上面的年龄平均值
use school;
select ceiling(avg(age)) from tb_student;
当然和天花板对应的还有floor函数,当然意思就是相反的了。
floor
use school;
select floor(avg(age)) from tb_student;