--分组函数
select avg(salary),max(salary),min(salary),sum(salary) from employees
运行结果
--判断大小
select max(last_name),min(last_name),max(hire_date),min(hire_date) from employees
运行结果
--计数
select count(employee_id),count(last_name),count(hire_date) from employees
运行结果
--求平均值
select avg(salary),sum(salary)/count(salary) from employees;
运行结果
--计算不为空
select count(commission_pct) from employees
运行结果
--
select count(distinct department_id) from employees
--查出员工表里面的平均工资
select department_id,avg(salary)
from employees
group by department_id
运行结果
--查出员工表里面的平均工资
select department_id,job_id,avg(salary)
from employees
group by department_id,job_id
运行结果
--查出员工表里面的平均工资大于6000 以及平均工资
select department_id,avg(salary)
from employees
having avg(salary)>6000
--where department_id in (40,60,80)
group by department_id