定义:
AVG 函数返回数值列的平均值。NULL 值不包括在计算中。
语法:
SELECT AVG(column_name) FROM table_name
-- 实际操作(计算salary的平均值):
SELECT avg(salary) AS "平均工资" FROM employee ;
-- 综合实际操作:
SELECT title,
COUNT(salary) AS "统计每组数据",
SUM(salary) AS "统计工资总和",
MAX(salary) "统计每组最大值",
MIN(salary) "统计每组最小值",
AVG(salary) "统计平均值" FROM employee
GROUP BY title
ORDER BY avg(salary) DESC;