GROUP BY 使用 HAVING
SELECT department, COUNT(*) AS "Man_Power"
FROM employees
GROUP BY department
HAVING COUNT(*) >= 10;
使用 GROUP BY ... HAVING
过滤聚合记录类似于使用 SELECT ... WHERE
过滤单个记录。
你也可以说 HAVING Man_Power >= 10
,因为 HAVING
理解别名。
SELECT department, COUNT(*) AS "Man_Power"
FROM employees
GROUP BY department
HAVING COUNT(*) >= 10;
使用 GROUP BY ... HAVING
过滤聚合记录类似于使用 SELECT ... WHERE
过滤单个记录。
你也可以说 HAVING Man_Power >= 10
,因为 HAVING
理解别名。