您可以使用 ORDER BY 子句以特定方式对 GROUP BY 的结果排序。
以下查询将求出每一产品的平均价格并按平均价格对结果排序:
SELECT Name, AVG( UnitPrice ) FROM Products GROUP BY Name ORDER BY AVG( UnitPrice ); |
Name | AVG(Products.UnitPrice) |
---|---|
Visor | 7 |
Baseball Cap | 9.5 |
Tee Shirt | 12.333333333 |
Shorts | 15 |
... | ... |
Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1 |