如何按 A 栏排序,然后按 B 栏排序?

如何编写 SQL,以便结果可以先按列 A 排序,然后按列 B 排序,如下所示:

SELECT * FROM tbl WHERE predictor ORDER by col_A and ORDER by col_B
98710 次浏览
ORDER BY col_A, col_B

The SQLite website has syntax diagrams explaining the SQL grammar supported by SQLite.

Just feed a comma separated list of columns to ORDER BY:

SELECT * from table WHERE table.foo=bar ORDER BY colA, colB

The ORDER BY clause causes the output rows to be sorted. The argument to ORDER BY is a list of expressions that are used as the key for the sort. The expressions do not have to be part of the result for a simple SELECT, but in a compound SELECT each sort expression must exactly match one of the result columns. Each sort expression may be optionally followed by a COLLATE keyword and the name of a collating function used for ordering text and/or keywords ASC or DESC to specify the sort order.

SELECT * FROM tbl WHERE predictor ORDER by col_A, col_B