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

SQL Anywhere 12.0.1 » SQL Anywhere Server - SQL Usage » Query and modify data » Queries » Aggregate functions in queries


Restricting groups

You have already seen how to restrict rows in a result set using the WHERE clause. You restrict the rows in groups using the HAVING clause.

 List all sales representatives with more than 55 orders
  • In Interactive SQL, execute the following query:

    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
 See also