分组查询
SELECT MAX(salary),job_id FROM employees GROUP BY job_id;
SELECT COUNT(*),location_id FROM departments GROUP BY location_id;
SELECT AVG(salary),department_id FROM employees WHERE email LIKE '%a%' GROUP BY department_id;
SELECT MAX(salary),manager_id FROM employees WHERE commission_pct IS NOT NULL GROUP BY manager_id;
SELECT COUNT(*),department_id FROM employees GROUP BY department_id;
SELECT COUNT(*),department_id FROM employees GROUP BY department_id HAVING COUNT(*)>2;
SELECT job_id,MAX(salary) FROM employees WHERE commission_pct IS NOT NULL GROUP BY job_id HAVING MAX(salary)>12000;
SELECT AVG(salary), department_id, job_id FROM employees GROUP BY department_id, job_id;
SELECT AVG(salary), department_id, job_id FROM employees GROUP BY department_id, job_id ORDER BY AVG(salary) DESC;