Skip to main content
Order by specifies that the output be sorted and how. You can order by multiple properties by stating each variable in the ORDER BY clause. Each property may specify its sort order with ASC/ASCENDING or DESC/DESCENDING. If no order is specified, it defaults to ascending. The result will be sorted by the first variable listed. For equal values, it will go to the next property in the ORDER BY clause, and so on.
Below we sort our friends by height. For equal heights, weight is used to break ties.

Frequently Asked Questions

If no direction is specified, ORDER BY defaults to ascending (ASC) order.
Yes. List multiple properties separated by commas. The result is sorted by the first property, then ties are broken by subsequent properties in order.
Yes. You can order by any expression or alias that appears in the RETURN or WITH clause, including computed values and aggregations.