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
理解別名。