SQL聚合函数

count(*)总数
select count(*) from person;
select count(*) from person where age=18;
max最大值 min最小值
select max(age) from person;
select min(id) from person where age=17;
sum求和 avg平均值(默认4位小数)
select sum(age) from person where gender=1;
select avg(age) from person where gender=1;
select sum(age)/count(*)  from person where gender=1;
round四舍五入
select round(avg(age),2)  from person where gender=1;

你可能感兴趣的:(SQL聚合函数)