ORDER BY column1 DESC, column2
每当两行或更多行column1
column1
(降序)对所有内容进行排序column2
(升序,这是默认设置)对所有内容进行排序。
其他答案缺少一个具体的示例,因此请按以下步骤进行:
给定以下人员表:
FirstName | LastName | YearOfBirth
----------------------------------------
Thomas | Alva Edison | 1847
Benjamin | Franklin | 1706
Thomas | More | 1478
Thomas | Jefferson | 1826
如果执行以下查询:
SELECT * FROM People ORDER BY FirstName DESC, YearOfBirth ASC
结果集将如下所示:
FirstName | LastName | YearOfBirth
----------------------------------------
Thomas | More | 1478
Thomas | Jefferson | 1826
Thomas | Alva Edison | 1847
Benjamin | Franklin | 1706
SELECT *
FROM mytable
ORDER BY
column1 DESC, column2 ASC