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

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Summarizing, Grouping, and Sorting Query Results » The ORDER BY clause: sorting query results

Explicitly limiting the number of rows returned by a query Next Page

ORDER BY and GROUP BY


You can use an ORDER BY clause to order the results of a GROUP BY in a particular way.

Example

The following query finds the average price of each product and orders the results by average price:

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