blob: e33deeecc0dbf67da77933f3ae2bfc14a9990db1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# ORDER BY
Sorting the `SELECT` result using a comma-separated list of sorting criteria. As a criteria, you can use a column value or an expression on columns. Ordering by column sequence number is not supported (`ORDER BY N` where `N` is a number).
Each criteria can be followed by the sorting direction:
- `ASC`: Sorting in the ascending order. Applied by default.
- `DESC`: Sorting in the descending order.
Multiple sorting criteria will be applied left-to-right.
## Example
```yql
SELECT key, string_column
FROM my_table
ORDER BY key DESC, LENGTH(string_column) ASC;
```
You can also use `ORDER BY` for [window functions](../window.md).
|