#1. 查询公司员工工资的最大值,最小值,平均值,总和
SELECT SUM(salary),MAX(salary),MIN(salary),AVG(salary),COUNT(salary) FROM employees
#工资去重
SELECT
sum( DISTINCT salary ),
sum( salary )
FROM
employees
#查询有几种工资SELECT count(DISTINCT salary) FROM employees
#统计工资的个数SELECT count(salary) FROM employees
#统计总行数即总记录条数
SELECT count(*) FROM employees
SELECT count(1) FROM employees
#2. 查询员工表中的最大入职时间和最小入职时间的相差天数 (DIFFRENCE)
SELECT
datediff(
max( hiredate ),
min( hiredate )) AS ‘相差天数‘
FROM
employees
#3. 查询部门编号为90的员工个数SELECT count(*) FROM employees WHERE department_id=90