Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 12.0.0 (中文) » SQL Anywhere 服务器 - SQL 的用法 » 查询和修改数据 » 查询数据 » 集合函数

 

限制组

您已经知道了如何使用 WHERE 子句来限制结果集中的行。您可以使用 HAVING 子句来限制组中的行。

 ♦  列出其订单数超过 55 的所有销售代表
  • 在 Interactive SQL 中,执行以下查询:

    SELECT SalesRepresentative, COUNT( * ) AS orders
    FROM SalesOrders KEY JOIN Employees
    GROUP BY SalesRepresentative
    HAVING count( * ) > 55
    ORDER BY orders DESC;
    SalesRepresentative orders
    299 114
    129 57
    1142 57
    467 56

另请参见HAVING 子句:选择数据组