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

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - SQL Usage » Queries and data modification » Summarizing, grouping, and sorting query results » The GROUP BY clause: Organizing query results into groups

 

GROUP BY with multiple columns

You can list more than one expression in the GROUP BY clause—that is, you can group a table by any combination of expressions.

The following query lists the average price of products, grouped first by name and then by size:

SELECT Name, Size, AVG( UnitPrice )
   FROM Products
   GROUP BY Name, Size;
Name Size AVG(Products.UnitPrice)
Baseball Cap One size fits all 9.5
Sweatshirt Large 24
Tee Shirt Large 14
Tee Shirt One size fits all 14
... ... ...