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

SQL Anywhere 11.0.1 (中文) » SQL Anywhere 服务器 - SQL 的用法 » 查询和修改数据 » 对查询结果进行汇总、分组和排序 » ORDER BY 子句:查询结果排序

 

ORDER BY 和 GROUP BY

您可以使用 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
... ...