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

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Summarizing, Grouping, and Sorting Query Results

Aggregate functions and NULL Next Page

The GROUP BY clause: organizing query results into groups

The GROUP BY clause divides the output of a table into groups. You can GROUP BY one or more column names, or by the results of computed columns.

Order of clauses

A GROUP BY clause must always appear before a HAVING clause. If a WHERE clause and a GROUP BY clause are present, the WHERE clause must appear before the GROUP BY clause.

HAVING clauses and WHERE clauses can both be used in a single query. Conditions in the HAVING clause logically restrict the rows of the result only after the groups have been constructed. Criteria in the WHERE clause are logically evaluated before the groups are constructed, and so save time.

Using GROUP BY with aggregate functions