• 首先执行子查询。
  • 向主查询中的having子句返回结果。

    案例:

    需求:查询最低工资大于110号部门最低工资的部门id和其最低工资
    1. SELECT department_id,MIN(salary)
    2. FROM employees
    3. WHERE department_id IS NOT NULL
    4. GROUP BY department_id
    5. HAVING MIN(salary) > (
    6. SELECT MIN(salary)
    7. FROM employees
    8. WHERE department_id = 110
    9. );