分组函数测试题:

#1.查询公司员工工资的最大值,最小值,平均值,总和

SELECT MAX(salary) mx_sal,MIN(salary)  mi_sal,AVG(salary)  ag_sal,SUM(salary) sm_sal

FROM employees;

#2.查询员工表中的最大入职时间和最小入职时间的相差天数(DIFFRENCE)

SELECT DATEDIFF(MAX(hiredate),MIN(hiredate))  DIFFRENCE FROM employees;

#3.查询部门编号为90的员工个数

SELECT COUNT(*) 个数

FROM employees

WHERE department_id=90;

你可能感兴趣的:(分组函数测试题:)