After packet screening conditions, the result of screening is to do a screening, it is placed at the end, if the result of screening and a screening of independent, then in the middle
Case # 1: Query number of employees of the department> 2
SELECT
COUNT(*),department_id
FROM
employees
GROUP BY
department_id
HAVING
COUNT(*)>2;
#: Maximum wage jobs have to query each employee bonuses> jobs numbered 12,000 and the highest salary
SELECT
MAX(salary),job_id
FROM
employees
WHERE
commission_pct IS NOT NULL
GROUP BY
job_id
HAVING
MAX(salary)>12000; #筛选12000放在分组后是因为,要等Max计算完再开始筛选
# Inquiry leading number> leading men of each employee's minimum wage> 102 leading number 5000, and its lowest wages
SELECT
MIN(salary),manager_id
FROM
employees
WHERE
manager_id>102
GROUP BY
manager_id
HAVING MIN(salary)>5000;