GROUP BY and the SQL/2003 standard

The SQL/2003 standard for GROUP BY requires the following:

  • A column used in an expression of the SELECT clause must be in the GROUP BY clause. Otherwise, the expression using that column is an aggregate function.
  • A GROUP BY expression can only contain column names from the select list, but not those used only as arguments for vector aggregates.

A standard GROUP BY with vector aggregate functions produces one row with one value per group.

SQL Anywhere support an extension that allows aggregate functions in the HAVING clause, even if they do not exist in the select list or GROUP BY clause.