SQL聚合函数

2020-02-05  本文已影响0人  冷煖自知
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;
上一篇下一篇

猜你喜欢

热点阅读