mysql 聚合函数(2)

平均 svg

  select avg(sal + IFNULL(comm,0)) as avg_sal from t_emp

总和 sum

select sum(sal + IFNULL(comm,0)) as sum_sal from t_emp 

最大 max

select max(sal + IFNULL(comm,0)) as max_sal from t_emp 

最小 min

select min(sal + IFNULL(comm,0)) as min_sal from t_emp 

总数 count

select count(*) as cout from t_emp 

分组查询

select deptno, avg(sal) from t_emp
GROUP BY deptno

猜你喜欢

转载自www.cnblogs.com/ericblog1992/p/11316713.html