forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
4.0 KiB
4.0 KiB
SORT BY
Function
This statement is used to achieve the partial sorting of tables according to fields.
Syntax
1 2 3 | SELECT attr_expr_list FROM table_reference SORT BY col_name [ASC | DESC] [,col_name [ASC | DESC],...]; |
Keyword
- ASC/DESC: ASC sorts from the lowest value to the highest value. DESC sorts from the highest value to the lowest value. ASC is the default sort order.
- SORT BY: Used together with GROUP BY to perform local sorting of a single column or multiple columns for PARTITION.
Precautions
The to-be-sorted table must exist. If this statement is used to sort a table that does not exist, an error is reported.
Example
To sort the student table in ascending order of the score field in Reducer, run the following statement:
1 2 | SELECT * FROM student SORT BY score; |
Parent topic: Sorting