SQL HAVING 关键字
HAVING
使用HAVING
命令代替WHERE和聚合函数。
以下SQL列出了每个Country的客户数量。仅包括拥有超过5个客户的Country:
实例
SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country HAVING COUNT(CustomerID) > 5;运行实例»
实例
SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country HAVING COUNT(CustomerID) > 5 ORDER BY COUNT(CustomerID) DESC;运行实例»