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 サーバー SQL の使用法 » データの問い合わせと修正 » クエリ結果の要約、グループ化、ソート » GROUP BY 句:クエリ結果のグループへの編成

 

複数のカラムを使用した GROUP BY

GROUP BY 句に 1 つ以上の式をリストできます。つまり、式の組み合わせによって、テーブルをグループ化できます。

次のクエリは、まず名前別にグループ化し、次にサイズ別にグループ化した製品の平均価格をリストします。

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
... ... ...