**分組函數,也叫聚合函數,統計函數等,主要有**
>[info]max()
min()
sum()
avg()
count()
......以上分組函數都會自動忽略null值
<br/>
```
select sum(salary) 總和,ROUND(avg(salary),2) 平均,max(salary) 最大,
min(salary) 最小,count(*) 個數 from employees; -- round用于保留小數個數,會四舍五入
```
@ ifnull(expres,expres),當null值需要參與運算時,用ifnull()轉變為其他值
```
SELECT first_name,commission_pct,salary*12*(1+IFNULL(commission_pct,0)) 年薪 from employees
-- 因為commission_pct有很多null值,null與任何數做運算結果都為null,所以通過ifnull()函數將null值轉為0
```
@ 分組函數不能與其他字段混用,即使能輸出,結果也是錯誤的
```
select avg(salary),employee_id from employees
```